Explicit casting
This commit is contained in:
parent
ef425d638a
commit
ab6d1c5d02
31 changed files with 171 additions and 153 deletions
|
|
@ -21,8 +21,9 @@
|
||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
#include <benchmark/benchmark.h>
|
#include "Config.h"
|
||||||
#include "ADSREnvelope.h"
|
#include "ADSREnvelope.h"
|
||||||
|
#include <benchmark/benchmark.h>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <random>
|
#include <random>
|
||||||
#include <numeric>
|
#include <numeric>
|
||||||
|
|
@ -44,12 +45,12 @@ static void Point(benchmark::State& state) {
|
||||||
for (auto _ : state) {
|
for (auto _ : state) {
|
||||||
envelope.reset(attack, release, 1.0, fixedAmount, decay, fixedAmount);
|
envelope.reset(attack, release, 1.0, fixedAmount, decay, fixedAmount);
|
||||||
envelope.startRelease(releaseTime);
|
envelope.startRelease(releaseTime);
|
||||||
for(int offset = 0; offset < envelopeSize; offset += state.range(0))
|
for(int offset = 0; offset < envelopeSize; offset += static_cast<int>(state.range(0)))
|
||||||
for (auto& out: output)
|
for (auto& out: output)
|
||||||
out = envelope.getNextValue();
|
out = envelope.getNextValue();
|
||||||
benchmark::DoNotOptimize(output);
|
benchmark::DoNotOptimize(output);
|
||||||
}
|
}
|
||||||
state.counters["Per block"] = benchmark::Counter(envelopeSize / state.range(0), benchmark::Counter::kIsRate);
|
state.counters["Per block"] = benchmark::Counter(envelopeSize / static_cast<double>(state.range(0)), benchmark::Counter::kIsRate);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void Block(benchmark::State& state) {
|
static void Block(benchmark::State& state) {
|
||||||
|
|
@ -58,14 +59,14 @@ static void Block(benchmark::State& state) {
|
||||||
for (auto _ : state) {
|
for (auto _ : state) {
|
||||||
envelope.reset(attack, release, 1.0, fixedAmount, decay, fixedAmount);
|
envelope.reset(attack, release, 1.0, fixedAmount, decay, fixedAmount);
|
||||||
envelope.startRelease(releaseTime);
|
envelope.startRelease(releaseTime);
|
||||||
for(int offset = 0; offset < envelopeSize; offset += state.range(0))
|
for(int offset = 0; offset < envelopeSize; offset += static_cast<int>(state.range(0)))
|
||||||
envelope.getBlock(absl::MakeSpan(output));
|
envelope.getBlock(absl::MakeSpan(output));
|
||||||
benchmark::DoNotOptimize(output);
|
benchmark::DoNotOptimize(output);
|
||||||
}
|
}
|
||||||
|
|
||||||
state.counters["Per block"] = benchmark::Counter(envelopeSize / state.range(0), benchmark::Counter::kIsRate);
|
state.counters["Per block"] = benchmark::Counter(envelopeSize / static_cast<double>(state.range(0)), benchmark::Counter::kIsRate);
|
||||||
}
|
}
|
||||||
|
|
||||||
BENCHMARK(Point)->RangeMultiplier(2)->Range((2<<6), (2<<11));
|
BENCHMARK(Point)->RangeMultiplier(2)->Range((2<<6), (2<<11));
|
||||||
BENCHMARK(Block)->RangeMultiplier(2)->Range((2<<6), (2<<11));
|
BENCHMARK(Block)->RangeMultiplier(2)->Range((2<<6), (2<<11));
|
||||||
BENCHMARK_MAIN();
|
BENCHMARK_MAIN();
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@
|
||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
#include "Config.h"
|
||||||
#include <benchmark/benchmark.h>
|
#include <benchmark/benchmark.h>
|
||||||
#include <absl/types/span.h>
|
#include <absl/types/span.h>
|
||||||
#include <random>
|
#include <random>
|
||||||
|
|
@ -111,7 +112,7 @@ static void Low(benchmark::State& state) {
|
||||||
std::vector<float> output(state.range(0));
|
std::vector<float> output(state.range(0));
|
||||||
std::random_device rd { };
|
std::random_device rd { };
|
||||||
std::mt19937 gen { rd() };
|
std::mt19937 gen { rd() };
|
||||||
|
|
||||||
std::normal_distribution<float> dist { };
|
std::normal_distribution<float> dist { };
|
||||||
std::generate(input.begin(), input.end(), [&]() {
|
std::generate(input.begin(), input.end(), [&]() {
|
||||||
return dist(gen);
|
return dist(gen);
|
||||||
|
|
@ -126,7 +127,7 @@ static void High(benchmark::State& state) {
|
||||||
std::vector<float> output(state.range(0));
|
std::vector<float> output(state.range(0));
|
||||||
std::random_device rd { };
|
std::random_device rd { };
|
||||||
std::mt19937 gen { rd() };
|
std::mt19937 gen { rd() };
|
||||||
|
|
||||||
std::normal_distribution<float> dist { };
|
std::normal_distribution<float> dist { };
|
||||||
std::generate(input.begin(), input.end(), [&]() {
|
std::generate(input.begin(), input.end(), [&]() {
|
||||||
return dist(gen);
|
return dist(gen);
|
||||||
|
|
@ -141,7 +142,7 @@ static void High_Raw(benchmark::State& state) {
|
||||||
std::vector<float> output(state.range(0));
|
std::vector<float> output(state.range(0));
|
||||||
std::random_device rd { };
|
std::random_device rd { };
|
||||||
std::mt19937 gen { rd() };
|
std::mt19937 gen { rd() };
|
||||||
|
|
||||||
std::normal_distribution<float> dist { };
|
std::normal_distribution<float> dist { };
|
||||||
std::generate(input.begin(), input.end(), [&]() {
|
std::generate(input.begin(), input.end(), [&]() {
|
||||||
return dist(gen);
|
return dist(gen);
|
||||||
|
|
@ -156,7 +157,7 @@ static void High_SSE(benchmark::State& state) {
|
||||||
std::vector<float> output(state.range(0));
|
std::vector<float> output(state.range(0));
|
||||||
std::random_device rd { };
|
std::random_device rd { };
|
||||||
std::mt19937 gen { rd() };
|
std::mt19937 gen { rd() };
|
||||||
|
|
||||||
std::normal_distribution<float> dist { };
|
std::normal_distribution<float> dist { };
|
||||||
std::generate(input.begin(), input.end(), [&]() {
|
std::generate(input.begin(), input.end(), [&]() {
|
||||||
return dist(gen);
|
return dist(gen);
|
||||||
|
|
@ -171,4 +172,4 @@ BENCHMARK(Low)->RangeMultiplier(2)->Range((2<<5), (2<<10));
|
||||||
BENCHMARK(High)->RangeMultiplier(2)->Range((2<<5), (2<<10));
|
BENCHMARK(High)->RangeMultiplier(2)->Range((2<<5), (2<<10));
|
||||||
BENCHMARK(High_Raw)->RangeMultiplier(2)->Range((2<<5), (2<<10));
|
BENCHMARK(High_Raw)->RangeMultiplier(2)->Range((2<<5), (2<<10));
|
||||||
BENCHMARK(High_SSE)->RangeMultiplier(2)->Range((2<<5), (2<<10));
|
BENCHMARK(High_SSE)->RangeMultiplier(2)->Range((2<<5), (2<<10));
|
||||||
BENCHMARK_MAIN();
|
BENCHMARK_MAIN();
|
||||||
|
|
|
||||||
|
|
@ -21,13 +21,13 @@
|
||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
#include "SIMDHelpers.h"
|
||||||
#include <benchmark/benchmark.h>
|
#include <benchmark/benchmark.h>
|
||||||
#include <random>
|
#include <random>
|
||||||
#include <numeric>
|
#include <numeric>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include "SIMDHelpers.h"
|
|
||||||
|
|
||||||
class AddArray : public benchmark::Fixture {
|
class AddArray : public benchmark::Fixture {
|
||||||
public:
|
public:
|
||||||
|
|
@ -113,4 +113,4 @@ BENCHMARK_REGISTER_F(AddArray, Scalar)->RangeMultiplier(4)->Range(1 << 2, 1 << 1
|
||||||
BENCHMARK_REGISTER_F(AddArray, SIMD)->RangeMultiplier(4)->Range(1 << 2, 1 << 12);
|
BENCHMARK_REGISTER_F(AddArray, SIMD)->RangeMultiplier(4)->Range(1 << 2, 1 << 12);
|
||||||
BENCHMARK_REGISTER_F(AddArray, Scalar_Unaligned)->RangeMultiplier(4)->Range(1 << 2, 1 << 12);
|
BENCHMARK_REGISTER_F(AddArray, Scalar_Unaligned)->RangeMultiplier(4)->Range(1 << 2, 1 << 12);
|
||||||
BENCHMARK_REGISTER_F(AddArray, SIMD_Unaligned)->RangeMultiplier(4)->Range(1 << 2, 1 << 12);
|
BENCHMARK_REGISTER_F(AddArray, SIMD_Unaligned)->RangeMultiplier(4)->Range(1 << 2, 1 << 12);
|
||||||
BENCHMARK_MAIN();
|
BENCHMARK_MAIN();
|
||||||
|
|
|
||||||
|
|
@ -21,13 +21,13 @@
|
||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
#include "SIMDHelpers.h"
|
||||||
#include <benchmark/benchmark.h>
|
#include <benchmark/benchmark.h>
|
||||||
#include <random>
|
#include <random>
|
||||||
#include <numeric>
|
#include <numeric>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include "SIMDHelpers.h"
|
|
||||||
|
|
||||||
class CopyArray : public benchmark::Fixture {
|
class CopyArray : public benchmark::Fixture {
|
||||||
public:
|
public:
|
||||||
|
|
@ -98,4 +98,4 @@ BENCHMARK_REGISTER_F(CopyArray, SIMD)->RangeMultiplier(4)->Range(1 << 4, 1 << 16
|
||||||
BENCHMARK_REGISTER_F(CopyArray, StdCopy_Unaligned)->RangeMultiplier(4)->Range(1 << 4, 1 << 16);
|
BENCHMARK_REGISTER_F(CopyArray, StdCopy_Unaligned)->RangeMultiplier(4)->Range(1 << 4, 1 << 16);
|
||||||
BENCHMARK_REGISTER_F(CopyArray, Scalar_Unaligned)->RangeMultiplier(4)->Range(1 << 4, 1 << 16);
|
BENCHMARK_REGISTER_F(CopyArray, Scalar_Unaligned)->RangeMultiplier(4)->Range(1 << 4, 1 << 16);
|
||||||
BENCHMARK_REGISTER_F(CopyArray, SIMD_Unaligned)->RangeMultiplier(4)->Range(1 << 4, 1 << 16);
|
BENCHMARK_REGISTER_F(CopyArray, SIMD_Unaligned)->RangeMultiplier(4)->Range(1 << 4, 1 << 16);
|
||||||
BENCHMARK_MAIN();
|
BENCHMARK_MAIN();
|
||||||
|
|
|
||||||
|
|
@ -21,20 +21,20 @@
|
||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
#include "SIMDHelpers.h"
|
||||||
#include <benchmark/benchmark.h>
|
#include <benchmark/benchmark.h>
|
||||||
#include <random>
|
#include <random>
|
||||||
#include <numeric>
|
#include <numeric>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include "SIMDHelpers.h"
|
|
||||||
|
|
||||||
class CumArray : public benchmark::Fixture {
|
class CumArray : public benchmark::Fixture {
|
||||||
public:
|
public:
|
||||||
void SetUp(const ::benchmark::State& state) {
|
void SetUp(const ::benchmark::State& state) {
|
||||||
std::random_device rd { };
|
std::random_device rd { };
|
||||||
std::mt19937 gen { rd() };
|
std::mt19937 gen { rd() };
|
||||||
std::uniform_real_distribution<float> dist { 0.1, 1 };
|
std::uniform_real_distribution<float> dist { 0.1f, 1.0f };
|
||||||
input = std::vector<float>(state.range(0));
|
input = std::vector<float>(state.range(0));
|
||||||
output = std::vector<float>(state.range(0));
|
output = std::vector<float>(state.range(0));
|
||||||
std::generate(input.begin(), input.end(), [&]() { return dist(gen); });
|
std::generate(input.begin(), input.end(), [&]() { return dist(gen); });
|
||||||
|
|
@ -82,4 +82,4 @@ BENCHMARK_REGISTER_F(CumArray, Sum_Scalar)->RangeMultiplier(4)->Range(1 << 2, 1
|
||||||
BENCHMARK_REGISTER_F(CumArray, Sum_SIMD)->RangeMultiplier(4)->Range(1 << 2, 1 << 12);
|
BENCHMARK_REGISTER_F(CumArray, Sum_SIMD)->RangeMultiplier(4)->Range(1 << 2, 1 << 12);
|
||||||
BENCHMARK_REGISTER_F(CumArray, Sum_Scalar_Unaligned)->RangeMultiplier(4)->Range(1 << 2, 1 << 12);
|
BENCHMARK_REGISTER_F(CumArray, Sum_Scalar_Unaligned)->RangeMultiplier(4)->Range(1 << 2, 1 << 12);
|
||||||
BENCHMARK_REGISTER_F(CumArray, Sum_SIMD_Unaligned)->RangeMultiplier(4)->Range(1 << 2, 1 << 12);
|
BENCHMARK_REGISTER_F(CumArray, Sum_SIMD_Unaligned)->RangeMultiplier(4)->Range(1 << 2, 1 << 12);
|
||||||
BENCHMARK_MAIN();
|
BENCHMARK_MAIN();
|
||||||
|
|
|
||||||
|
|
@ -21,13 +21,13 @@
|
||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
#include "SIMDHelpers.h"
|
||||||
#include <benchmark/benchmark.h>
|
#include <benchmark/benchmark.h>
|
||||||
#include <random>
|
#include <random>
|
||||||
#include <numeric>
|
#include <numeric>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include "SIMDHelpers.h"
|
|
||||||
#include "absl/types/span.h"
|
#include "absl/types/span.h"
|
||||||
|
|
||||||
class DiffArray : public benchmark::Fixture {
|
class DiffArray : public benchmark::Fixture {
|
||||||
|
|
@ -35,7 +35,7 @@ public:
|
||||||
void SetUp(const ::benchmark::State& state) {
|
void SetUp(const ::benchmark::State& state) {
|
||||||
std::random_device rd { };
|
std::random_device rd { };
|
||||||
std::mt19937 gen { rd() };
|
std::mt19937 gen { rd() };
|
||||||
std::uniform_real_distribution<float> dist { 0.1, 1 };
|
std::uniform_real_distribution<float> dist { 0.1f, 1.0f };
|
||||||
input = std::vector<float>(state.range(0));
|
input = std::vector<float>(state.range(0));
|
||||||
output = std::vector<float>(state.range(0));
|
output = std::vector<float>(state.range(0));
|
||||||
std::generate(input.begin(), input.end(), [&]() { return dist(gen); });
|
std::generate(input.begin(), input.end(), [&]() { return dist(gen); });
|
||||||
|
|
@ -84,4 +84,4 @@ BENCHMARK_REGISTER_F(DiffArray, Diff_Scalar)->RangeMultiplier(4)->Range(1 << 2,
|
||||||
BENCHMARK_REGISTER_F(DiffArray, Diff_SIMD)->RangeMultiplier(4)->Range(1 << 2, 1 << 12);
|
BENCHMARK_REGISTER_F(DiffArray, Diff_SIMD)->RangeMultiplier(4)->Range(1 << 2, 1 << 12);
|
||||||
BENCHMARK_REGISTER_F(DiffArray, Diff_Scalar_Unaligned)->RangeMultiplier(4)->Range(1 << 2, 1 << 12);
|
BENCHMARK_REGISTER_F(DiffArray, Diff_Scalar_Unaligned)->RangeMultiplier(4)->Range(1 << 2, 1 << 12);
|
||||||
BENCHMARK_REGISTER_F(DiffArray, Diff_SIMD_Unaligned)->RangeMultiplier(4)->Range(1 << 2, 1 << 12);
|
BENCHMARK_REGISTER_F(DiffArray, Diff_SIMD_Unaligned)->RangeMultiplier(4)->Range(1 << 2, 1 << 12);
|
||||||
BENCHMARK_MAIN();
|
BENCHMARK_MAIN();
|
||||||
|
|
|
||||||
|
|
@ -21,13 +21,13 @@
|
||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
#include "SIMDHelpers.h"
|
||||||
#include <benchmark/benchmark.h>
|
#include <benchmark/benchmark.h>
|
||||||
#include <random>
|
#include <random>
|
||||||
#include <numeric>
|
#include <numeric>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include "SIMDHelpers.h"
|
|
||||||
|
|
||||||
|
|
||||||
class Divide : public benchmark::Fixture {
|
class Divide : public benchmark::Fixture {
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@
|
||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
#include "SIMDHelpers.h"
|
||||||
#include <benchmark/benchmark.h>
|
#include <benchmark/benchmark.h>
|
||||||
#include <random>
|
#include <random>
|
||||||
#include <numeric>
|
#include <numeric>
|
||||||
|
|
@ -28,7 +29,6 @@
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include "EventEnvelopes.h"
|
#include "EventEnvelopes.h"
|
||||||
#include "SIMDHelpers.h"
|
|
||||||
#include "absl/types/span.h"
|
#include "absl/types/span.h"
|
||||||
|
|
||||||
#include "FloatEnvelopes.cpp"
|
#include "FloatEnvelopes.cpp"
|
||||||
|
|
@ -59,7 +59,7 @@ BENCHMARK_DEFINE_F(EnvelopeFixture, Linear)(benchmark::State& state) {
|
||||||
sfz::LinearEnvelope<float> envelope;
|
sfz::LinearEnvelope<float> envelope;
|
||||||
for (auto _ : state)
|
for (auto _ : state)
|
||||||
{
|
{
|
||||||
envelope.registerEvent(state.range(0) - 1, dist(gen));
|
envelope.registerEvent(static_cast<int>(state.range(0) - 1), dist(gen));
|
||||||
envelope.getBlock(absl::MakeSpan(output));
|
envelope.getBlock(absl::MakeSpan(output));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -68,7 +68,7 @@ BENCHMARK_DEFINE_F(EnvelopeFixture, LinearQuantized)(benchmark::State& state) {
|
||||||
sfz::LinearEnvelope<float> envelope;
|
sfz::LinearEnvelope<float> envelope;
|
||||||
for (auto _ : state)
|
for (auto _ : state)
|
||||||
{
|
{
|
||||||
envelope.registerEvent(state.range(0) - 1, dist(gen));
|
envelope.registerEvent(static_cast<int>(state.range(0) - 1), dist(gen));
|
||||||
envelope.getQuantizedBlock(absl::MakeSpan(output), 0.5);
|
envelope.getQuantizedBlock(absl::MakeSpan(output), 0.5);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -77,7 +77,7 @@ BENCHMARK_DEFINE_F(EnvelopeFixture, Multiplicative)(benchmark::State& state) {
|
||||||
sfz::MultiplicativeEnvelope<float> envelope;
|
sfz::MultiplicativeEnvelope<float> envelope;
|
||||||
for (auto _ : state)
|
for (auto _ : state)
|
||||||
{
|
{
|
||||||
envelope.registerEvent(state.range(0) - 1, dist(gen));
|
envelope.registerEvent(static_cast<int>(state.range(0) - 1), dist(gen));
|
||||||
envelope.getBlock(absl::MakeSpan(output));
|
envelope.getBlock(absl::MakeSpan(output));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -86,7 +86,7 @@ BENCHMARK_DEFINE_F(EnvelopeFixture, MultiplicativeQuantized)(benchmark::State& s
|
||||||
sfz::MultiplicativeEnvelope<float> envelope;
|
sfz::MultiplicativeEnvelope<float> envelope;
|
||||||
for (auto _ : state)
|
for (auto _ : state)
|
||||||
{
|
{
|
||||||
envelope.registerEvent(state.range(0) - 1, dist(gen));
|
envelope.registerEvent(static_cast<int>(state.range(0) - 1), dist(gen));
|
||||||
envelope.getQuantizedBlock(absl::MakeSpan(output), 1.5);
|
envelope.getQuantizedBlock(absl::MakeSpan(output), 1.5);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -96,4 +96,4 @@ BENCHMARK_REGISTER_F(EnvelopeFixture, Linear)->RangeMultiplier(4)->Range(1 << 2,
|
||||||
BENCHMARK_REGISTER_F(EnvelopeFixture, LinearQuantized)->RangeMultiplier(4)->Range(1 << 2, 1 << 12);
|
BENCHMARK_REGISTER_F(EnvelopeFixture, LinearQuantized)->RangeMultiplier(4)->Range(1 << 2, 1 << 12);
|
||||||
BENCHMARK_REGISTER_F(EnvelopeFixture, Multiplicative)->RangeMultiplier(4)->Range(1 << 2, 1 << 12);
|
BENCHMARK_REGISTER_F(EnvelopeFixture, Multiplicative)->RangeMultiplier(4)->Range(1 << 2, 1 << 12);
|
||||||
BENCHMARK_REGISTER_F(EnvelopeFixture, MultiplicativeQuantized)->RangeMultiplier(4)->Range(1 << 2, 1 << 12);
|
BENCHMARK_REGISTER_F(EnvelopeFixture, MultiplicativeQuantized)->RangeMultiplier(4)->Range(1 << 2, 1 << 12);
|
||||||
BENCHMARK_MAIN();
|
BENCHMARK_MAIN();
|
||||||
|
|
|
||||||
|
|
@ -21,8 +21,8 @@
|
||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
#include <benchmark/benchmark.h>
|
|
||||||
#include "SIMDHelpers.h"
|
#include "SIMDHelpers.h"
|
||||||
|
#include <benchmark/benchmark.h>
|
||||||
#include "Buffer.h"
|
#include "Buffer.h"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <random>
|
#include <random>
|
||||||
|
|
@ -84,4 +84,4 @@ BENCHMARK(FillScalar)->RangeMultiplier(4)->Range((1<<2), (1<<12));
|
||||||
BENCHMARK(FillSIMD)->RangeMultiplier(4)->Range((1<<2), (1<<12));
|
BENCHMARK(FillSIMD)->RangeMultiplier(4)->Range((1<<2), (1<<12));
|
||||||
BENCHMARK(FillScalar_unaligned)->RangeMultiplier(4)->Range((1<<2), (1<<12));
|
BENCHMARK(FillScalar_unaligned)->RangeMultiplier(4)->Range((1<<2), (1<<12));
|
||||||
BENCHMARK(FillSIMD_unaligned)->RangeMultiplier(4)->Range((1<<2), (1<<12));
|
BENCHMARK(FillSIMD_unaligned)->RangeMultiplier(4)->Range((1<<2), (1<<12));
|
||||||
BENCHMARK_MAIN();
|
BENCHMARK_MAIN();
|
||||||
|
|
|
||||||
|
|
@ -20,12 +20,12 @@
|
||||||
// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
#include "Buffer.h"
|
||||||
#include <benchmark/benchmark.h>
|
#include <benchmark/benchmark.h>
|
||||||
#include <sndfile.hh>
|
#include <sndfile.hh>
|
||||||
#define DR_FLAC_IMPLEMENTATION
|
#define DR_FLAC_IMPLEMENTATION
|
||||||
#include "dr_flac.h"
|
#include "dr_flac.h"
|
||||||
#include "ghc/filesystem.hpp"
|
#include "ghc/filesystem.hpp"
|
||||||
#include "Buffer.h"
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
|
||||||
|
|
@ -21,13 +21,13 @@
|
||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
#include "SIMDHelpers.h"
|
||||||
#include <benchmark/benchmark.h>
|
#include <benchmark/benchmark.h>
|
||||||
#include <random>
|
#include <random>
|
||||||
#include <numeric>
|
#include <numeric>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include "SIMDHelpers.h"
|
|
||||||
|
|
||||||
class GainSingle : public benchmark::Fixture {
|
class GainSingle : public benchmark::Fixture {
|
||||||
public:
|
public:
|
||||||
|
|
@ -140,4 +140,4 @@ BENCHMARK_REGISTER_F(GainArray, Scalar)->RangeMultiplier(4)->Range(1 << 2, 1 <<
|
||||||
BENCHMARK_REGISTER_F(GainArray, SIMD)->RangeMultiplier(4)->Range(1 << 2, 1 << 12);
|
BENCHMARK_REGISTER_F(GainArray, SIMD)->RangeMultiplier(4)->Range(1 << 2, 1 << 12);
|
||||||
BENCHMARK_REGISTER_F(GainArray, Scalar_Unaligned)->RangeMultiplier(4)->Range(1 << 2, 1 << 12);
|
BENCHMARK_REGISTER_F(GainArray, Scalar_Unaligned)->RangeMultiplier(4)->Range(1 << 2, 1 << 12);
|
||||||
BENCHMARK_REGISTER_F(GainArray, SIMD_Unaligned)->RangeMultiplier(4)->Range(1 << 2, 1 << 12);
|
BENCHMARK_REGISTER_F(GainArray, SIMD_Unaligned)->RangeMultiplier(4)->Range(1 << 2, 1 << 12);
|
||||||
BENCHMARK_MAIN();
|
BENCHMARK_MAIN();
|
||||||
|
|
|
||||||
|
|
@ -21,12 +21,12 @@
|
||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
#include "SIMDHelpers.h"
|
||||||
#include <benchmark/benchmark.h>
|
#include <benchmark/benchmark.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <random>
|
#include <random>
|
||||||
#include <numeric>
|
#include <numeric>
|
||||||
#include <absl/algorithm/container.h>
|
#include <absl/algorithm/container.h>
|
||||||
#include "SIMDHelpers.h"
|
|
||||||
|
|
||||||
// In this one we have an array of jumps
|
// In this one we have an array of jumps
|
||||||
|
|
||||||
|
|
@ -90,4 +90,4 @@ BENCHMARK_REGISTER_F(InterpolationCast, Scalar)->RangeMultiplier(2)->Range((2<<6
|
||||||
BENCHMARK_REGISTER_F(InterpolationCast, SIMD)->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, Scalar_Unaligned)->RangeMultiplier(2)->Range((2<<6), (2<<12));
|
||||||
BENCHMARK_REGISTER_F(InterpolationCast, SIMD_Unaligned)->RangeMultiplier(2)->Range((2<<6), (2<<12));
|
BENCHMARK_REGISTER_F(InterpolationCast, SIMD_Unaligned)->RangeMultiplier(2)->Range((2<<6), (2<<12));
|
||||||
BENCHMARK_MAIN();
|
BENCHMARK_MAIN();
|
||||||
|
|
|
||||||
|
|
@ -22,11 +22,11 @@
|
||||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
#include <benchmark/benchmark.h>
|
#include <benchmark/benchmark.h>
|
||||||
|
#include "SIMDHelpers.h"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <random>
|
#include <random>
|
||||||
#include <numeric>
|
#include <numeric>
|
||||||
#include <absl/algorithm/container.h>
|
#include <absl/algorithm/container.h>
|
||||||
#include "SIMDHelpers.h"
|
|
||||||
|
|
||||||
// In this one we have an array of indices
|
// In this one we have an array of indices
|
||||||
|
|
||||||
|
|
@ -92,4 +92,4 @@ BENCHMARK_REGISTER_F(LoopingFixture, Scalar)->RangeMultiplier(2)->Range((2<<6),
|
||||||
BENCHMARK_REGISTER_F(LoopingFixture, SIMD)->RangeMultiplier(2)->Range((2<<6), (2<<12));
|
BENCHMARK_REGISTER_F(LoopingFixture, SIMD)->RangeMultiplier(2)->Range((2<<6), (2<<12));
|
||||||
BENCHMARK_REGISTER_F(LoopingFixture, Scalar_Unaligned)->RangeMultiplier(2)->Range((2<<6), (2<<12));
|
BENCHMARK_REGISTER_F(LoopingFixture, Scalar_Unaligned)->RangeMultiplier(2)->Range((2<<6), (2<<12));
|
||||||
BENCHMARK_REGISTER_F(LoopingFixture, SIMD_Unaligned)->RangeMultiplier(2)->Range((2<<6), (2<<12));
|
BENCHMARK_REGISTER_F(LoopingFixture, SIMD_Unaligned)->RangeMultiplier(2)->Range((2<<6), (2<<12));
|
||||||
BENCHMARK_MAIN();
|
BENCHMARK_MAIN();
|
||||||
|
|
|
||||||
|
|
@ -21,13 +21,13 @@
|
||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
#include "SIMDHelpers.h"
|
||||||
#include <benchmark/benchmark.h>
|
#include <benchmark/benchmark.h>
|
||||||
#include <random>
|
#include <random>
|
||||||
#include <numeric>
|
#include <numeric>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include "SIMDHelpers.h"
|
|
||||||
|
|
||||||
class MultiplyAdd : public benchmark::Fixture {
|
class MultiplyAdd : public benchmark::Fixture {
|
||||||
public:
|
public:
|
||||||
|
|
@ -93,4 +93,4 @@ BENCHMARK_REGISTER_F(MultiplyAdd, Scalar)->RangeMultiplier(4)->Range(1 << 2, 1 <
|
||||||
BENCHMARK_REGISTER_F(MultiplyAdd, SIMD)->RangeMultiplier(4)->Range(1 << 2, 1 << 12);
|
BENCHMARK_REGISTER_F(MultiplyAdd, SIMD)->RangeMultiplier(4)->Range(1 << 2, 1 << 12);
|
||||||
BENCHMARK_REGISTER_F(MultiplyAdd, Scalar_Unaligned)->RangeMultiplier(4)->Range(1 << 2, 1 << 12);
|
BENCHMARK_REGISTER_F(MultiplyAdd, Scalar_Unaligned)->RangeMultiplier(4)->Range(1 << 2, 1 << 12);
|
||||||
BENCHMARK_REGISTER_F(MultiplyAdd, SIMD_Unaligned)->RangeMultiplier(4)->Range(1 << 2, 1 << 12);
|
BENCHMARK_REGISTER_F(MultiplyAdd, SIMD_Unaligned)->RangeMultiplier(4)->Range(1 << 2, 1 << 12);
|
||||||
BENCHMARK_MAIN();
|
BENCHMARK_MAIN();
|
||||||
|
|
|
||||||
|
|
@ -21,13 +21,13 @@
|
||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
#include "SIMDHelpers.h"
|
||||||
#include <benchmark/benchmark.h>
|
#include <benchmark/benchmark.h>
|
||||||
#include <random>
|
#include <random>
|
||||||
#include <numeric>
|
#include <numeric>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include "SIMDHelpers.h"
|
|
||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
#include "absl/types/span.h"
|
#include "absl/types/span.h"
|
||||||
|
|
||||||
|
|
@ -36,7 +36,7 @@ public:
|
||||||
void SetUp(const ::benchmark::State& state) {
|
void SetUp(const ::benchmark::State& state) {
|
||||||
std::random_device rd { };
|
std::random_device rd { };
|
||||||
std::mt19937 gen { rd() };
|
std::mt19937 gen { rd() };
|
||||||
std::uniform_real_distribution<float> dist { 0.001, 1 };
|
std::uniform_real_distribution<float> dist { 0.001f, 1.0f };
|
||||||
pan = std::vector<float>(state.range(0));
|
pan = std::vector<float>(state.range(0));
|
||||||
left = std::vector<float>(state.range(0));
|
left = std::vector<float>(state.range(0));
|
||||||
right = std::vector<float>(state.range(0));
|
right = std::vector<float>(state.range(0));
|
||||||
|
|
@ -93,4 +93,4 @@ BENCHMARK_DEFINE_F(PanArray, BlockOps)(benchmark::State& state) {
|
||||||
BENCHMARK_REGISTER_F(PanArray, Scalar)->RangeMultiplier(4)->Range(1 << 2, 1 << 12);
|
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, SIMD)->RangeMultiplier(4)->Range(1 << 2, 1 << 12);
|
||||||
BENCHMARK_REGISTER_F(PanArray, BlockOps)->RangeMultiplier(4)->Range(1 << 2, 1 << 12);
|
BENCHMARK_REGISTER_F(PanArray, BlockOps)->RangeMultiplier(4)->Range(1 << 2, 1 << 12);
|
||||||
BENCHMARK_MAIN();
|
BENCHMARK_MAIN();
|
||||||
|
|
|
||||||
|
|
@ -21,10 +21,10 @@
|
||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
#include "SIMDHelpers.h"
|
||||||
#include <benchmark/benchmark.h>
|
#include <benchmark/benchmark.h>
|
||||||
#include <random>
|
#include <random>
|
||||||
#include <absl/algorithm/container.h>
|
#include <absl/algorithm/container.h>
|
||||||
#include "SIMDHelpers.h"
|
|
||||||
#include "absl/types/span.h"
|
#include "absl/types/span.h"
|
||||||
|
|
||||||
constexpr int bigNumber { 2399132 };
|
constexpr int bigNumber { 2399132 };
|
||||||
|
|
@ -33,8 +33,8 @@ class IterOffset : public benchmark::Fixture {
|
||||||
public:
|
public:
|
||||||
void SetUp(const ::benchmark::State& state [[maybe_unused]]) {
|
void SetUp(const ::benchmark::State& state [[maybe_unused]]) {
|
||||||
std::random_device rd { };
|
std::random_device rd { };
|
||||||
std::mt19937 gen { rd() };
|
std::mt19937 gen { rd() };
|
||||||
std::uniform_real_distribution<float> dist { 0.001, 1 };
|
std::uniform_real_distribution<float> dist { 0.001f, 1.0f };
|
||||||
std::uniform_int_distribution<int> jumpDist { 0, 3 };
|
std::uniform_int_distribution<int> jumpDist { 0, 3 };
|
||||||
source = std::vector<float>(bigNumber);
|
source = std::vector<float>(bigNumber);
|
||||||
result.resize(state.range(0));
|
result.resize(state.range(0));
|
||||||
|
|
@ -57,7 +57,7 @@ public:
|
||||||
|
|
||||||
BENCHMARK_DEFINE_F(IterOffset, Pointers)(benchmark::State& state) {
|
BENCHMARK_DEFINE_F(IterOffset, Pointers)(benchmark::State& state) {
|
||||||
for (auto _ : state)
|
for (auto _ : state)
|
||||||
{
|
{
|
||||||
sfz::diff<int>(offsets, absl::MakeSpan(jumps));
|
sfz::diff<int>(offsets, absl::MakeSpan(jumps));
|
||||||
auto jump = jumps.begin();
|
auto jump = jumps.begin();
|
||||||
auto in = source.begin();
|
auto in = source.begin();
|
||||||
|
|
@ -71,7 +71,7 @@ BENCHMARK_DEFINE_F(IterOffset, Pointers)(benchmark::State& state) {
|
||||||
|
|
||||||
BENCHMARK_DEFINE_F(IterOffset, Offsets)(benchmark::State& state) {
|
BENCHMARK_DEFINE_F(IterOffset, Offsets)(benchmark::State& state) {
|
||||||
for (auto _ : state)
|
for (auto _ : state)
|
||||||
{
|
{
|
||||||
auto offset = offsets.begin();
|
auto offset = offsets.begin();
|
||||||
auto out = result.begin();
|
auto out = result.begin();
|
||||||
while (offset < offsets.end())
|
while (offset < offsets.end())
|
||||||
|
|
@ -83,4 +83,4 @@ BENCHMARK_DEFINE_F(IterOffset, Offsets)(benchmark::State& state) {
|
||||||
// Register the function as a benchmark
|
// Register the function as a benchmark
|
||||||
BENCHMARK_REGISTER_F(IterOffset, Pointers)->RangeMultiplier(4)->Range((1 << 2), (1 << 12));
|
BENCHMARK_REGISTER_F(IterOffset, Pointers)->RangeMultiplier(4)->Range((1 << 2), (1 << 12));
|
||||||
BENCHMARK_REGISTER_F(IterOffset, Offsets)->RangeMultiplier(4)->Range((1 << 2), (1 << 12));
|
BENCHMARK_REGISTER_F(IterOffset, Offsets)->RangeMultiplier(4)->Range((1 << 2), (1 << 12));
|
||||||
BENCHMARK_MAIN();
|
BENCHMARK_MAIN();
|
||||||
|
|
|
||||||
|
|
@ -21,9 +21,9 @@
|
||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
#include "SIMDHelpers.h"
|
||||||
#include <benchmark/benchmark.h>
|
#include <benchmark/benchmark.h>
|
||||||
#include <random>
|
#include <random>
|
||||||
#include "SIMDHelpers.h"
|
|
||||||
#include "Buffer.h"
|
#include "Buffer.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -204,4 +204,4 @@ BENCHMARK(LogDomainScalar)->RangeMultiplier(4)->Range((1 << 2), (1 << 12));
|
||||||
BENCHMARK(LogDomainSIMD)->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(LogDomainScalarUnaligned)->RangeMultiplier(4)->Range((1 << 2), (1 << 12));
|
||||||
BENCHMARK(LogDomainSIMDUnaligned)->RangeMultiplier(4)->Range((1 << 2), (1 << 12));
|
BENCHMARK(LogDomainSIMDUnaligned)->RangeMultiplier(4)->Range((1 << 2), (1 << 12));
|
||||||
BENCHMARK_MAIN();
|
BENCHMARK_MAIN();
|
||||||
|
|
|
||||||
|
|
@ -20,11 +20,11 @@
|
||||||
// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
#include "SIMDHelpers.h"
|
||||||
|
#include "Buffer.h"
|
||||||
#include <benchmark/benchmark.h>
|
#include <benchmark/benchmark.h>
|
||||||
#include <sndfile.hh>
|
#include <sndfile.hh>
|
||||||
#include "ghc/filesystem.hpp"
|
#include "ghc/filesystem.hpp"
|
||||||
#include "Buffer.h"
|
|
||||||
#include "SIMDHelpers.h"
|
|
||||||
#define DR_WAV_IMPLEMENTATION
|
#define DR_WAV_IMPLEMENTATION
|
||||||
#include "dr_wav.h"
|
#include "dr_wav.h"
|
||||||
#include "AudioBuffer.h"
|
#include "AudioBuffer.h"
|
||||||
|
|
|
||||||
|
|
@ -21,9 +21,9 @@
|
||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
#include <benchmark/benchmark.h>
|
|
||||||
#include "SIMDHelpers.h"
|
#include "SIMDHelpers.h"
|
||||||
#include "Buffer.h"
|
#include "Buffer.h"
|
||||||
|
#include <benchmark/benchmark.h>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <numeric>
|
#include <numeric>
|
||||||
#include <absl/types/span.h>
|
#include <absl/types/span.h>
|
||||||
|
|
@ -96,4 +96,4 @@ BENCHMARK(Scalar_Unaligned)->Range((8<<10), (8<<20));
|
||||||
BENCHMARK(SSE_Unaligned)->Range((8<<10), (8<<20));
|
BENCHMARK(SSE_Unaligned)->Range((8<<10), (8<<20));
|
||||||
BENCHMARK(Scalar_Unaligned_2)->Range((8<<10), (8<<20));
|
BENCHMARK(Scalar_Unaligned_2)->Range((8<<10), (8<<20));
|
||||||
BENCHMARK(SSE_Unaligned_2)->Range((8<<10), (8<<20));
|
BENCHMARK(SSE_Unaligned_2)->Range((8<<10), (8<<20));
|
||||||
BENCHMARK_MAIN();
|
BENCHMARK_MAIN();
|
||||||
|
|
|
||||||
|
|
@ -20,11 +20,11 @@
|
||||||
// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
#include "Buffer.h"
|
||||||
|
#include "SIMDHelpers.h"
|
||||||
#include <benchmark/benchmark.h>
|
#include <benchmark/benchmark.h>
|
||||||
#include <sndfile.hh>
|
#include <sndfile.hh>
|
||||||
#include "ghc/filesystem.hpp"
|
#include "ghc/filesystem.hpp"
|
||||||
#include "Buffer.h"
|
|
||||||
#include "SIMDHelpers.h"
|
|
||||||
#include "Oversampler.h"
|
#include "Oversampler.h"
|
||||||
#include "AudioBuffer.h"
|
#include "AudioBuffer.h"
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
@ -139,14 +139,14 @@ BENCHMARK_DEFINE_F(FileFixture, ResampleAtOnce)(benchmark::State& state) {
|
||||||
sndfile.readf(buffer.data(), numFrames);
|
sndfile.readf(buffer.data(), numFrames);
|
||||||
sfz::readInterleaved<float>(buffer, output->getSpan(0), output->getSpan(1));
|
sfz::readInterleaved<float>(buffer, output->getSpan(0), output->getSpan(1));
|
||||||
|
|
||||||
upsampler2x.process_block(temp.data(), output->channelReader(0), numFrames);
|
upsampler2x.process_block(temp.data(), output->channelReader(0), static_cast<long>(numFrames));
|
||||||
upsampler4x.process_block(output->channelWriter(0), temp.data(), numFrames * 2);
|
upsampler4x.process_block(output->channelWriter(0), temp.data(), static_cast<long>(numFrames * 2));
|
||||||
|
|
||||||
upsampler2x.clear_buffers();
|
upsampler2x.clear_buffers();
|
||||||
upsampler4x.clear_buffers();
|
upsampler4x.clear_buffers();
|
||||||
|
|
||||||
upsampler2x.process_block(temp.data(), output->channelReader(1), numFrames);
|
upsampler2x.process_block(temp.data(), output->channelReader(1), static_cast<long>(numFrames));
|
||||||
upsampler4x.process_block(output->channelWriter(1), temp.data(), numFrames * 2);
|
upsampler4x.process_block(output->channelWriter(1), temp.data(), static_cast<long>(numFrames * 2));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -189,11 +189,11 @@ BENCHMARK_DEFINE_F(FileFixture, ResampleInChunks)(benchmark::State& state) {
|
||||||
|
|
||||||
sfz::readInterleaved<float>(bufferChunk, leftSpan, rightSpan);
|
sfz::readInterleaved<float>(bufferChunk, leftSpan, rightSpan);
|
||||||
|
|
||||||
upsampler2xLeft.process_block(chunkSpan.data(), leftSpan.data(), thisChunkSize);
|
upsampler2xLeft.process_block(chunkSpan.data(), leftSpan.data(), static_cast<long>(thisChunkSize));
|
||||||
upsampler4xLeft.process_block(output->channelWriter(0) + outputFrameCounter, chunkSpan.data(), thisChunkSize * 2);
|
upsampler4xLeft.process_block(output->channelWriter(0) + outputFrameCounter, chunkSpan.data(), static_cast<long>(thisChunkSize * 2));
|
||||||
|
|
||||||
upsampler2xRight.process_block(chunkSpan.data(), rightSpan.data(), thisChunkSize);
|
upsampler2xRight.process_block(chunkSpan.data(), rightSpan.data(), static_cast<long>(thisChunkSize));
|
||||||
upsampler4xRight.process_block(output->channelWriter(1) + outputFrameCounter, chunkSpan.data(), thisChunkSize * 2);
|
upsampler4xRight.process_block(output->channelWriter(1) + outputFrameCounter, chunkSpan.data(), static_cast<long>(thisChunkSize * 2));
|
||||||
|
|
||||||
inputFrameCounter += chunkSize;
|
inputFrameCounter += chunkSize;
|
||||||
outputFrameCounter += chunkSize * 4;
|
outputFrameCounter += chunkSize * 4;
|
||||||
|
|
|
||||||
|
|
@ -21,12 +21,12 @@
|
||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
#include "SIMDHelpers.h"
|
||||||
#include <benchmark/benchmark.h>
|
#include <benchmark/benchmark.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <random>
|
#include <random>
|
||||||
#include <numeric>
|
#include <numeric>
|
||||||
#include <absl/algorithm/container.h>
|
#include <absl/algorithm/container.h>
|
||||||
#include "SIMDHelpers.h"
|
|
||||||
|
|
||||||
// In this one we have an array of indices
|
// In this one we have an array of indices
|
||||||
|
|
||||||
|
|
@ -91,4 +91,4 @@ BENCHMARK_REGISTER_F(SaturatingFixture, Scalar)->RangeMultiplier(2)->Range((2<<6
|
||||||
BENCHMARK_REGISTER_F(SaturatingFixture, SIMD)->RangeMultiplier(2)->Range((2<<6), (2<<12));
|
BENCHMARK_REGISTER_F(SaturatingFixture, SIMD)->RangeMultiplier(2)->Range((2<<6), (2<<12));
|
||||||
BENCHMARK_REGISTER_F(SaturatingFixture, Scalar_Unaligned)->RangeMultiplier(2)->Range((2<<6), (2<<12));
|
BENCHMARK_REGISTER_F(SaturatingFixture, Scalar_Unaligned)->RangeMultiplier(2)->Range((2<<6), (2<<12));
|
||||||
BENCHMARK_REGISTER_F(SaturatingFixture, SIMD_Unaligned)->RangeMultiplier(2)->Range((2<<6), (2<<12));
|
BENCHMARK_REGISTER_F(SaturatingFixture, SIMD_Unaligned)->RangeMultiplier(2)->Range((2<<6), (2<<12));
|
||||||
BENCHMARK_MAIN();
|
BENCHMARK_MAIN();
|
||||||
|
|
|
||||||
|
|
@ -21,13 +21,13 @@
|
||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
#include "SIMDHelpers.h"
|
||||||
#include <benchmark/benchmark.h>
|
#include <benchmark/benchmark.h>
|
||||||
#include <random>
|
#include <random>
|
||||||
#include <numeric>
|
#include <numeric>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include "SIMDHelpers.h"
|
|
||||||
|
|
||||||
class SubArray : public benchmark::Fixture {
|
class SubArray : public benchmark::Fixture {
|
||||||
public:
|
public:
|
||||||
|
|
@ -82,4 +82,4 @@ BENCHMARK_REGISTER_F(SubArray, Scalar)->RangeMultiplier(4)->Range(1 << 2, 1 << 1
|
||||||
BENCHMARK_REGISTER_F(SubArray, SIMD)->RangeMultiplier(4)->Range(1 << 2, 1 << 12);
|
BENCHMARK_REGISTER_F(SubArray, SIMD)->RangeMultiplier(4)->Range(1 << 2, 1 << 12);
|
||||||
BENCHMARK_REGISTER_F(SubArray, Scalar_Unaligned)->RangeMultiplier(4)->Range(1 << 2, 1 << 12);
|
BENCHMARK_REGISTER_F(SubArray, Scalar_Unaligned)->RangeMultiplier(4)->Range(1 << 2, 1 << 12);
|
||||||
BENCHMARK_REGISTER_F(SubArray, SIMD_Unaligned)->RangeMultiplier(4)->Range(1 << 2, 1 << 12);
|
BENCHMARK_REGISTER_F(SubArray, SIMD_Unaligned)->RangeMultiplier(4)->Range(1 << 2, 1 << 12);
|
||||||
BENCHMARK_MAIN();
|
BENCHMARK_MAIN();
|
||||||
|
|
|
||||||
|
|
@ -20,12 +20,12 @@
|
||||||
// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
#include "Buffer.h"
|
||||||
#include <benchmark/benchmark.h>
|
#include <benchmark/benchmark.h>
|
||||||
#include <sndfile.hh>
|
#include <sndfile.hh>
|
||||||
#define DR_WAV_IMPLEMENTATION
|
#define DR_WAV_IMPLEMENTATION
|
||||||
#include "dr_wav.h"
|
#include "dr_wav.h"
|
||||||
#include "ghc/filesystem.hpp"
|
#include "ghc/filesystem.hpp"
|
||||||
#include "Buffer.h"
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
|
||||||
|
|
@ -21,9 +21,9 @@
|
||||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
#include <benchmark/benchmark.h>
|
|
||||||
#include "SIMDHelpers.h"
|
#include "SIMDHelpers.h"
|
||||||
#include "Buffer.h"
|
#include "Buffer.h"
|
||||||
|
#include <benchmark/benchmark.h>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <numeric>
|
#include <numeric>
|
||||||
#include <absl/types/span.h>
|
#include <absl/types/span.h>
|
||||||
|
|
@ -106,4 +106,4 @@ BENCHMARK(Unaligned_Interleaved_Write)->Range((8<<10), (8<<20));
|
||||||
BENCHMARK(Unaligned_Interleaved_Write_SSE)->Range((8<<10), (8<<20));
|
BENCHMARK(Unaligned_Interleaved_Write_SSE)->Range((8<<10), (8<<20));
|
||||||
BENCHMARK(Unaligned_Interleaved_Write_2)->Range((8<<10), (8<<20));
|
BENCHMARK(Unaligned_Interleaved_Write_2)->Range((8<<10), (8<<20));
|
||||||
BENCHMARK(Unaligned_Interleaved_Write_SSE_2)->Range((8<<10), (8<<20));
|
BENCHMARK(Unaligned_Interleaved_Write_SSE_2)->Range((8<<10), (8<<20));
|
||||||
BENCHMARK_MAIN();
|
BENCHMARK_MAIN();
|
||||||
|
|
|
||||||
128
src/external/mathfuns/sse_mathfun.h
vendored
128
src/external/mathfuns/sse_mathfun.h
vendored
|
|
@ -35,7 +35,7 @@
|
||||||
|
|
||||||
#ifdef _MSC_VER /* visual c++ */
|
#ifdef _MSC_VER /* visual c++ */
|
||||||
# define ALIGN16_BEG __declspec(align(16))
|
# define ALIGN16_BEG __declspec(align(16))
|
||||||
# define ALIGN16_END
|
# define ALIGN16_END
|
||||||
#else /* gcc or icc */
|
#else /* gcc or icc */
|
||||||
# define ALIGN16_BEG
|
# define ALIGN16_BEG
|
||||||
# define ALIGN16_END __attribute__((aligned(16)))
|
# define ALIGN16_END __attribute__((aligned(16)))
|
||||||
|
|
@ -77,18 +77,18 @@ _PI32_CONST(2, 2);
|
||||||
_PI32_CONST(4, 4);
|
_PI32_CONST(4, 4);
|
||||||
_PI32_CONST(0x7f, 0x7f);
|
_PI32_CONST(0x7f, 0x7f);
|
||||||
|
|
||||||
_PS_CONST(cephes_SQRTHF, 0.707106781186547524);
|
_PS_CONST(cephes_SQRTHF, 0.707106781186547524f);
|
||||||
_PS_CONST(cephes_log_p0, 7.0376836292E-2);
|
_PS_CONST(cephes_log_p0, 7.0376836292E-2f);
|
||||||
_PS_CONST(cephes_log_p1, - 1.1514610310E-1);
|
_PS_CONST(cephes_log_p1, - 1.1514610310E-1f);
|
||||||
_PS_CONST(cephes_log_p2, 1.1676998740E-1);
|
_PS_CONST(cephes_log_p2, 1.1676998740E-1f);
|
||||||
_PS_CONST(cephes_log_p3, - 1.2420140846E-1);
|
_PS_CONST(cephes_log_p3, - 1.2420140846E-1f);
|
||||||
_PS_CONST(cephes_log_p4, + 1.4249322787E-1);
|
_PS_CONST(cephes_log_p4, + 1.4249322787E-1f);
|
||||||
_PS_CONST(cephes_log_p5, - 1.6668057665E-1);
|
_PS_CONST(cephes_log_p5, - 1.6668057665E-1f);
|
||||||
_PS_CONST(cephes_log_p6, + 2.0000714765E-1);
|
_PS_CONST(cephes_log_p6, + 2.0000714765E-1f);
|
||||||
_PS_CONST(cephes_log_p7, - 2.4999993993E-1);
|
_PS_CONST(cephes_log_p7, - 2.4999993993E-1f);
|
||||||
_PS_CONST(cephes_log_p8, + 3.3333331174E-1);
|
_PS_CONST(cephes_log_p8, + 3.3333331174E-1f);
|
||||||
_PS_CONST(cephes_log_q1, -2.12194440e-4);
|
_PS_CONST(cephes_log_q1, -2.12194440e-4f);
|
||||||
_PS_CONST(cephes_log_q2, 0.693359375);
|
_PS_CONST(cephes_log_q2, 0.693359375f);
|
||||||
|
|
||||||
#ifndef USE_SSE2
|
#ifndef USE_SSE2
|
||||||
typedef union xmm_mm_union {
|
typedef union xmm_mm_union {
|
||||||
|
|
@ -108,7 +108,7 @@ typedef union xmm_mm_union {
|
||||||
|
|
||||||
#endif // USE_SSE2
|
#endif // USE_SSE2
|
||||||
|
|
||||||
/* natural logarithm computed for 4 simultaneous float
|
/* natural logarithm computed for 4 simultaneous float
|
||||||
return NaN for x <= 0
|
return NaN for x <= 0
|
||||||
*/
|
*/
|
||||||
v4sf log_ps(v4sf x) {
|
v4sf log_ps(v4sf x) {
|
||||||
|
|
@ -148,7 +148,7 @@ v4sf log_ps(v4sf x) {
|
||||||
|
|
||||||
e = _mm_add_ps(e, one);
|
e = _mm_add_ps(e, one);
|
||||||
|
|
||||||
/* part2:
|
/* part2:
|
||||||
if( x < SQRTHF ) {
|
if( x < SQRTHF ) {
|
||||||
e -= 1;
|
e -= 1;
|
||||||
x = x + x - 1.0;
|
x = x + x - 1.0;
|
||||||
|
|
@ -183,7 +183,7 @@ v4sf log_ps(v4sf x) {
|
||||||
y = _mm_mul_ps(y, x);
|
y = _mm_mul_ps(y, x);
|
||||||
|
|
||||||
y = _mm_mul_ps(y, z);
|
y = _mm_mul_ps(y, z);
|
||||||
|
|
||||||
|
|
||||||
tmp = _mm_mul_ps(e, *(v4sf*)_ps_cephes_log_q1);
|
tmp = _mm_mul_ps(e, *(v4sf*)_ps_cephes_log_q1);
|
||||||
y = _mm_add_ps(y, tmp);
|
y = _mm_add_ps(y, tmp);
|
||||||
|
|
@ -202,16 +202,16 @@ v4sf log_ps(v4sf x) {
|
||||||
_PS_CONST(exp_hi, 88.3762626647949f);
|
_PS_CONST(exp_hi, 88.3762626647949f);
|
||||||
_PS_CONST(exp_lo, -88.3762626647949f);
|
_PS_CONST(exp_lo, -88.3762626647949f);
|
||||||
|
|
||||||
_PS_CONST(cephes_LOG2EF, 1.44269504088896341);
|
_PS_CONST(cephes_LOG2EF, 1.44269504088896341f);
|
||||||
_PS_CONST(cephes_exp_C1, 0.693359375);
|
_PS_CONST(cephes_exp_C1, 0.693359375f);
|
||||||
_PS_CONST(cephes_exp_C2, -2.12194440e-4);
|
_PS_CONST(cephes_exp_C2, -2.12194440e-4f);
|
||||||
|
|
||||||
_PS_CONST(cephes_exp_p0, 1.9875691500E-4);
|
_PS_CONST(cephes_exp_p0, 1.9875691500E-4f);
|
||||||
_PS_CONST(cephes_exp_p1, 1.3981999507E-3);
|
_PS_CONST(cephes_exp_p1, 1.3981999507E-3f);
|
||||||
_PS_CONST(cephes_exp_p2, 8.3334519073E-3);
|
_PS_CONST(cephes_exp_p2, 8.3334519073E-3f);
|
||||||
_PS_CONST(cephes_exp_p3, 4.1665795894E-2);
|
_PS_CONST(cephes_exp_p3, 4.1665795894E-2f);
|
||||||
_PS_CONST(cephes_exp_p4, 1.6666665459E-1);
|
_PS_CONST(cephes_exp_p4, 1.6666665459E-1f);
|
||||||
_PS_CONST(cephes_exp_p5, 5.0000001201E-1);
|
_PS_CONST(cephes_exp_p5, 5.0000001201E-1f);
|
||||||
|
|
||||||
v4sf exp_ps(v4sf x) {
|
v4sf exp_ps(v4sf x) {
|
||||||
v4sf tmp = _mm_setzero_ps(), fx;
|
v4sf tmp = _mm_setzero_ps(), fx;
|
||||||
|
|
@ -242,7 +242,7 @@ v4sf exp_ps(v4sf x) {
|
||||||
tmp = _mm_cvtepi32_ps(emm0);
|
tmp = _mm_cvtepi32_ps(emm0);
|
||||||
#endif
|
#endif
|
||||||
/* if greater, substract 1 */
|
/* if greater, substract 1 */
|
||||||
v4sf mask = _mm_cmpgt_ps(tmp, fx);
|
v4sf mask = _mm_cmpgt_ps(tmp, fx);
|
||||||
mask = _mm_and_ps(mask, one);
|
mask = _mm_and_ps(mask, one);
|
||||||
fx = _mm_sub_ps(tmp, mask);
|
fx = _mm_sub_ps(tmp, mask);
|
||||||
|
|
||||||
|
|
@ -252,7 +252,7 @@ v4sf exp_ps(v4sf x) {
|
||||||
x = _mm_sub_ps(x, z);
|
x = _mm_sub_ps(x, z);
|
||||||
|
|
||||||
z = _mm_mul_ps(x,x);
|
z = _mm_mul_ps(x,x);
|
||||||
|
|
||||||
v4sf y = *(v4sf*)_ps_cephes_exp_p0;
|
v4sf y = *(v4sf*)_ps_cephes_exp_p0;
|
||||||
y = _mm_mul_ps(y, x);
|
y = _mm_mul_ps(y, x);
|
||||||
y = _mm_add_ps(y, *(v4sf*)_ps_cephes_exp_p1);
|
y = _mm_add_ps(y, *(v4sf*)_ps_cephes_exp_p1);
|
||||||
|
|
@ -275,10 +275,10 @@ v4sf exp_ps(v4sf x) {
|
||||||
mm1 = _mm_cvttps_pi32(z);
|
mm1 = _mm_cvttps_pi32(z);
|
||||||
mm0 = _mm_add_pi32(mm0, *(v2si*)_pi32_0x7f);
|
mm0 = _mm_add_pi32(mm0, *(v2si*)_pi32_0x7f);
|
||||||
mm1 = _mm_add_pi32(mm1, *(v2si*)_pi32_0x7f);
|
mm1 = _mm_add_pi32(mm1, *(v2si*)_pi32_0x7f);
|
||||||
mm0 = _mm_slli_pi32(mm0, 23);
|
mm0 = _mm_slli_pi32(mm0, 23);
|
||||||
mm1 = _mm_slli_pi32(mm1, 23);
|
mm1 = _mm_slli_pi32(mm1, 23);
|
||||||
|
|
||||||
v4sf pow2n;
|
v4sf pow2n;
|
||||||
COPY_MM_TO_XMM(mm0, mm1, pow2n);
|
COPY_MM_TO_XMM(mm0, mm1, pow2n);
|
||||||
_mm_empty();
|
_mm_empty();
|
||||||
#else
|
#else
|
||||||
|
|
@ -291,16 +291,16 @@ v4sf exp_ps(v4sf x) {
|
||||||
return y;
|
return y;
|
||||||
}
|
}
|
||||||
|
|
||||||
_PS_CONST(minus_cephes_DP1, -0.78515625);
|
_PS_CONST(minus_cephes_DP1, -0.78515625f);
|
||||||
_PS_CONST(minus_cephes_DP2, -2.4187564849853515625e-4);
|
_PS_CONST(minus_cephes_DP2, -2.4187564849853515625e-4f);
|
||||||
_PS_CONST(minus_cephes_DP3, -3.77489497744594108e-8);
|
_PS_CONST(minus_cephes_DP3, -3.77489497744594108e-8f);
|
||||||
_PS_CONST(sincof_p0, -1.9515295891E-4);
|
_PS_CONST(sincof_p0, -1.9515295891E-4f);
|
||||||
_PS_CONST(sincof_p1, 8.3321608736E-3);
|
_PS_CONST(sincof_p1, 8.3321608736E-3f);
|
||||||
_PS_CONST(sincof_p2, -1.6666654611E-1);
|
_PS_CONST(sincof_p2, -1.6666654611E-1f);
|
||||||
_PS_CONST(coscof_p0, 2.443315711809948E-005);
|
_PS_CONST(coscof_p0, 2.443315711809948E-005f);
|
||||||
_PS_CONST(coscof_p1, -1.388731625493765E-003);
|
_PS_CONST(coscof_p1, -1.388731625493765E-003f);
|
||||||
_PS_CONST(coscof_p2, 4.166664568298827E-002);
|
_PS_CONST(coscof_p2, 4.166664568298827E-002f);
|
||||||
_PS_CONST(cephes_FOPI, 1.27323954473516); // 4 / M_PI
|
_PS_CONST(cephes_FOPI, 1.27323954473516f); // 4 / M_PI
|
||||||
|
|
||||||
|
|
||||||
/* evaluation of 4 sines at onces, using only SSE1+MMX intrinsics so
|
/* evaluation of 4 sines at onces, using only SSE1+MMX intrinsics so
|
||||||
|
|
@ -344,7 +344,7 @@ v4sf sin_ps(v4sf x) { // any x
|
||||||
x = _mm_and_ps(x, *(v4sf*)_ps_inv_sign_mask);
|
x = _mm_and_ps(x, *(v4sf*)_ps_inv_sign_mask);
|
||||||
/* extract the sign bit (upper one) */
|
/* extract the sign bit (upper one) */
|
||||||
sign_bit = _mm_and_ps(sign_bit, *(v4sf*)_ps_sign_mask);
|
sign_bit = _mm_and_ps(sign_bit, *(v4sf*)_ps_sign_mask);
|
||||||
|
|
||||||
/* scale by 4/Pi */
|
/* scale by 4/Pi */
|
||||||
y = _mm_mul_ps(x, *(v4sf*)_ps_cephes_FOPI);
|
y = _mm_mul_ps(x, *(v4sf*)_ps_cephes_FOPI);
|
||||||
|
|
||||||
|
|
@ -359,7 +359,7 @@ v4sf sin_ps(v4sf x) { // any x
|
||||||
/* get the swap sign flag */
|
/* get the swap sign flag */
|
||||||
emm0 = _mm_and_si128(emm2, *(v4si*)_pi32_4);
|
emm0 = _mm_and_si128(emm2, *(v4si*)_pi32_4);
|
||||||
emm0 = _mm_slli_epi32(emm0, 29);
|
emm0 = _mm_slli_epi32(emm0, 29);
|
||||||
/* get the polynom selection mask
|
/* get the polynom selection mask
|
||||||
there is one polynom for 0 <= x <= Pi/4
|
there is one polynom for 0 <= x <= Pi/4
|
||||||
and another one for Pi/4<x<=Pi/2
|
and another one for Pi/4<x<=Pi/2
|
||||||
|
|
||||||
|
|
@ -367,11 +367,11 @@ v4sf sin_ps(v4sf x) { // any x
|
||||||
*/
|
*/
|
||||||
emm2 = _mm_and_si128(emm2, *(v4si*)_pi32_2);
|
emm2 = _mm_and_si128(emm2, *(v4si*)_pi32_2);
|
||||||
emm2 = _mm_cmpeq_epi32(emm2, _mm_setzero_si128());
|
emm2 = _mm_cmpeq_epi32(emm2, _mm_setzero_si128());
|
||||||
|
|
||||||
v4sf swap_sign_bit = _mm_castsi128_ps(emm0);
|
v4sf swap_sign_bit = _mm_castsi128_ps(emm0);
|
||||||
v4sf poly_mask = _mm_castsi128_ps(emm2);
|
v4sf poly_mask = _mm_castsi128_ps(emm2);
|
||||||
sign_bit = _mm_xor_ps(sign_bit, swap_sign_bit);
|
sign_bit = _mm_xor_ps(sign_bit, swap_sign_bit);
|
||||||
|
|
||||||
#else
|
#else
|
||||||
/* store the integer part of y in mm0:mm1 */
|
/* store the integer part of y in mm0:mm1 */
|
||||||
xmm2 = _mm_movehl_ps(xmm2, y);
|
xmm2 = _mm_movehl_ps(xmm2, y);
|
||||||
|
|
@ -399,8 +399,8 @@ v4sf sin_ps(v4sf x) { // any x
|
||||||
sign_bit = _mm_xor_ps(sign_bit, swap_sign_bit);
|
sign_bit = _mm_xor_ps(sign_bit, swap_sign_bit);
|
||||||
_mm_empty(); /* good-bye mmx */
|
_mm_empty(); /* good-bye mmx */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* The magic pass: "Extended precision modular arithmetic"
|
/* The magic pass: "Extended precision modular arithmetic"
|
||||||
x = ((x - y * DP1) - y * DP2) - y * DP3; */
|
x = ((x - y * DP1) - y * DP2) - y * DP3; */
|
||||||
xmm1 = *(v4sf*)_ps_minus_cephes_DP1;
|
xmm1 = *(v4sf*)_ps_minus_cephes_DP1;
|
||||||
xmm2 = *(v4sf*)_ps_minus_cephes_DP2;
|
xmm2 = *(v4sf*)_ps_minus_cephes_DP2;
|
||||||
|
|
@ -425,7 +425,7 @@ v4sf sin_ps(v4sf x) { // any x
|
||||||
v4sf tmp = _mm_mul_ps(z, *(v4sf*)_ps_0p5);
|
v4sf tmp = _mm_mul_ps(z, *(v4sf*)_ps_0p5);
|
||||||
y = _mm_sub_ps(y, tmp);
|
y = _mm_sub_ps(y, tmp);
|
||||||
y = _mm_add_ps(y, *(v4sf*)_ps_1);
|
y = _mm_add_ps(y, *(v4sf*)_ps_1);
|
||||||
|
|
||||||
/* Evaluate the second polynom (Pi/4 <= x <= 0) */
|
/* Evaluate the second polynom (Pi/4 <= x <= 0) */
|
||||||
|
|
||||||
v4sf y2 = *(v4sf*)_ps_sincof_p0;
|
v4sf y2 = *(v4sf*)_ps_sincof_p0;
|
||||||
|
|
@ -437,7 +437,7 @@ v4sf sin_ps(v4sf x) { // any x
|
||||||
y2 = _mm_mul_ps(y2, x);
|
y2 = _mm_mul_ps(y2, x);
|
||||||
y2 = _mm_add_ps(y2, x);
|
y2 = _mm_add_ps(y2, x);
|
||||||
|
|
||||||
/* select the correct result from the two polynoms */
|
/* select the correct result from the two polynoms */
|
||||||
xmm3 = poly_mask;
|
xmm3 = poly_mask;
|
||||||
y2 = _mm_and_ps(xmm3, y2); //, xmm3);
|
y2 = _mm_and_ps(xmm3, y2); //, xmm3);
|
||||||
y = _mm_andnot_ps(xmm3, y);
|
y = _mm_andnot_ps(xmm3, y);
|
||||||
|
|
@ -457,10 +457,10 @@ v4sf cos_ps(v4sf x) { // any x
|
||||||
#endif
|
#endif
|
||||||
/* take the absolute value */
|
/* take the absolute value */
|
||||||
x = _mm_and_ps(x, *(v4sf*)_ps_inv_sign_mask);
|
x = _mm_and_ps(x, *(v4sf*)_ps_inv_sign_mask);
|
||||||
|
|
||||||
/* scale by 4/Pi */
|
/* scale by 4/Pi */
|
||||||
y = _mm_mul_ps(x, *(v4sf*)_ps_cephes_FOPI);
|
y = _mm_mul_ps(x, *(v4sf*)_ps_cephes_FOPI);
|
||||||
|
|
||||||
#ifdef USE_SSE2
|
#ifdef USE_SSE2
|
||||||
/* store the integer part of y in mm0 */
|
/* store the integer part of y in mm0 */
|
||||||
emm2 = _mm_cvttps_epi32(y);
|
emm2 = _mm_cvttps_epi32(y);
|
||||||
|
|
@ -470,14 +470,14 @@ v4sf cos_ps(v4sf x) { // any x
|
||||||
y = _mm_cvtepi32_ps(emm2);
|
y = _mm_cvtepi32_ps(emm2);
|
||||||
|
|
||||||
emm2 = _mm_sub_epi32(emm2, *(v4si*)_pi32_2);
|
emm2 = _mm_sub_epi32(emm2, *(v4si*)_pi32_2);
|
||||||
|
|
||||||
/* get the swap sign flag */
|
/* get the swap sign flag */
|
||||||
emm0 = _mm_andnot_si128(emm2, *(v4si*)_pi32_4);
|
emm0 = _mm_andnot_si128(emm2, *(v4si*)_pi32_4);
|
||||||
emm0 = _mm_slli_epi32(emm0, 29);
|
emm0 = _mm_slli_epi32(emm0, 29);
|
||||||
/* get the polynom selection mask */
|
/* get the polynom selection mask */
|
||||||
emm2 = _mm_and_si128(emm2, *(v4si*)_pi32_2);
|
emm2 = _mm_and_si128(emm2, *(v4si*)_pi32_2);
|
||||||
emm2 = _mm_cmpeq_epi32(emm2, _mm_setzero_si128());
|
emm2 = _mm_cmpeq_epi32(emm2, _mm_setzero_si128());
|
||||||
|
|
||||||
v4sf sign_bit = _mm_castsi128_ps(emm0);
|
v4sf sign_bit = _mm_castsi128_ps(emm0);
|
||||||
v4sf poly_mask = _mm_castsi128_ps(emm2);
|
v4sf poly_mask = _mm_castsi128_ps(emm2);
|
||||||
#else
|
#else
|
||||||
|
|
@ -498,7 +498,7 @@ v4sf cos_ps(v4sf x) { // any x
|
||||||
mm2 = _mm_sub_pi32(mm2, *(v2si*)_pi32_2);
|
mm2 = _mm_sub_pi32(mm2, *(v2si*)_pi32_2);
|
||||||
mm3 = _mm_sub_pi32(mm3, *(v2si*)_pi32_2);
|
mm3 = _mm_sub_pi32(mm3, *(v2si*)_pi32_2);
|
||||||
|
|
||||||
/* get the swap sign flag in mm0:mm1 and the
|
/* get the swap sign flag in mm0:mm1 and the
|
||||||
polynom selection mask in mm2:mm3 */
|
polynom selection mask in mm2:mm3 */
|
||||||
|
|
||||||
mm0 = _mm_andnot_si64(mm2, *(v2si*)_pi32_4);
|
mm0 = _mm_andnot_si64(mm2, *(v2si*)_pi32_4);
|
||||||
|
|
@ -517,7 +517,7 @@ v4sf cos_ps(v4sf x) { // any x
|
||||||
COPY_MM_TO_XMM(mm2, mm3, poly_mask);
|
COPY_MM_TO_XMM(mm2, mm3, poly_mask);
|
||||||
_mm_empty(); /* good-bye mmx */
|
_mm_empty(); /* good-bye mmx */
|
||||||
#endif
|
#endif
|
||||||
/* The magic pass: "Extended precision modular arithmetic"
|
/* The magic pass: "Extended precision modular arithmetic"
|
||||||
x = ((x - y * DP1) - y * DP2) - y * DP3; */
|
x = ((x - y * DP1) - y * DP2) - y * DP3; */
|
||||||
xmm1 = *(v4sf*)_ps_minus_cephes_DP1;
|
xmm1 = *(v4sf*)_ps_minus_cephes_DP1;
|
||||||
xmm2 = *(v4sf*)_ps_minus_cephes_DP2;
|
xmm2 = *(v4sf*)_ps_minus_cephes_DP2;
|
||||||
|
|
@ -528,7 +528,7 @@ v4sf cos_ps(v4sf x) { // any x
|
||||||
x = _mm_add_ps(x, xmm1);
|
x = _mm_add_ps(x, xmm1);
|
||||||
x = _mm_add_ps(x, xmm2);
|
x = _mm_add_ps(x, xmm2);
|
||||||
x = _mm_add_ps(x, xmm3);
|
x = _mm_add_ps(x, xmm3);
|
||||||
|
|
||||||
/* Evaluate the first polynom (0 <= x <= Pi/4) */
|
/* Evaluate the first polynom (0 <= x <= Pi/4) */
|
||||||
y = *(v4sf*)_ps_coscof_p0;
|
y = *(v4sf*)_ps_coscof_p0;
|
||||||
v4sf z = _mm_mul_ps(x,x);
|
v4sf z = _mm_mul_ps(x,x);
|
||||||
|
|
@ -542,7 +542,7 @@ v4sf cos_ps(v4sf x) { // any x
|
||||||
v4sf tmp = _mm_mul_ps(z, *(v4sf*)_ps_0p5);
|
v4sf tmp = _mm_mul_ps(z, *(v4sf*)_ps_0p5);
|
||||||
y = _mm_sub_ps(y, tmp);
|
y = _mm_sub_ps(y, tmp);
|
||||||
y = _mm_add_ps(y, *(v4sf*)_ps_1);
|
y = _mm_add_ps(y, *(v4sf*)_ps_1);
|
||||||
|
|
||||||
/* Evaluate the second polynom (Pi/4 <= x <= 0) */
|
/* Evaluate the second polynom (Pi/4 <= x <= 0) */
|
||||||
|
|
||||||
v4sf y2 = *(v4sf*)_ps_sincof_p0;
|
v4sf y2 = *(v4sf*)_ps_sincof_p0;
|
||||||
|
|
@ -554,7 +554,7 @@ v4sf cos_ps(v4sf x) { // any x
|
||||||
y2 = _mm_mul_ps(y2, x);
|
y2 = _mm_mul_ps(y2, x);
|
||||||
y2 = _mm_add_ps(y2, x);
|
y2 = _mm_add_ps(y2, x);
|
||||||
|
|
||||||
/* select the correct result from the two polynoms */
|
/* select the correct result from the two polynoms */
|
||||||
xmm3 = poly_mask;
|
xmm3 = poly_mask;
|
||||||
y2 = _mm_and_ps(xmm3, y2); //, xmm3);
|
y2 = _mm_and_ps(xmm3, y2); //, xmm3);
|
||||||
y = _mm_andnot_ps(xmm3, y);
|
y = _mm_andnot_ps(xmm3, y);
|
||||||
|
|
@ -579,10 +579,10 @@ void sincos_ps(v4sf x, v4sf *s, v4sf *c) {
|
||||||
x = _mm_and_ps(x, *(v4sf*)_ps_inv_sign_mask);
|
x = _mm_and_ps(x, *(v4sf*)_ps_inv_sign_mask);
|
||||||
/* extract the sign bit (upper one) */
|
/* extract the sign bit (upper one) */
|
||||||
sign_bit_sin = _mm_and_ps(sign_bit_sin, *(v4sf*)_ps_sign_mask);
|
sign_bit_sin = _mm_and_ps(sign_bit_sin, *(v4sf*)_ps_sign_mask);
|
||||||
|
|
||||||
/* scale by 4/Pi */
|
/* scale by 4/Pi */
|
||||||
y = _mm_mul_ps(x, *(v4sf*)_ps_cephes_FOPI);
|
y = _mm_mul_ps(x, *(v4sf*)_ps_cephes_FOPI);
|
||||||
|
|
||||||
#ifdef USE_SSE2
|
#ifdef USE_SSE2
|
||||||
/* store the integer part of y in emm2 */
|
/* store the integer part of y in emm2 */
|
||||||
emm2 = _mm_cvttps_epi32(y);
|
emm2 = _mm_cvttps_epi32(y);
|
||||||
|
|
@ -638,7 +638,7 @@ void sincos_ps(v4sf x, v4sf *s, v4sf *c) {
|
||||||
COPY_MM_TO_XMM(mm2, mm3, poly_mask);
|
COPY_MM_TO_XMM(mm2, mm3, poly_mask);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* The magic pass: "Extended precision modular arithmetic"
|
/* The magic pass: "Extended precision modular arithmetic"
|
||||||
x = ((x - y * DP1) - y * DP2) - y * DP3; */
|
x = ((x - y * DP1) - y * DP2) - y * DP3; */
|
||||||
xmm1 = *(v4sf*)_ps_minus_cephes_DP1;
|
xmm1 = *(v4sf*)_ps_minus_cephes_DP1;
|
||||||
xmm2 = *(v4sf*)_ps_minus_cephes_DP2;
|
xmm2 = *(v4sf*)_ps_minus_cephes_DP2;
|
||||||
|
|
@ -670,7 +670,7 @@ void sincos_ps(v4sf x, v4sf *s, v4sf *c) {
|
||||||
|
|
||||||
sign_bit_sin = _mm_xor_ps(sign_bit_sin, swap_sign_bit_sin);
|
sign_bit_sin = _mm_xor_ps(sign_bit_sin, swap_sign_bit_sin);
|
||||||
|
|
||||||
|
|
||||||
/* Evaluate the first polynom (0 <= x <= Pi/4) */
|
/* Evaluate the first polynom (0 <= x <= Pi/4) */
|
||||||
v4sf z = _mm_mul_ps(x,x);
|
v4sf z = _mm_mul_ps(x,x);
|
||||||
y = *(v4sf*)_ps_coscof_p0;
|
y = *(v4sf*)_ps_coscof_p0;
|
||||||
|
|
@ -684,7 +684,7 @@ void sincos_ps(v4sf x, v4sf *s, v4sf *c) {
|
||||||
v4sf tmp = _mm_mul_ps(z, *(v4sf*)_ps_0p5);
|
v4sf tmp = _mm_mul_ps(z, *(v4sf*)_ps_0p5);
|
||||||
y = _mm_sub_ps(y, tmp);
|
y = _mm_sub_ps(y, tmp);
|
||||||
y = _mm_add_ps(y, *(v4sf*)_ps_1);
|
y = _mm_add_ps(y, *(v4sf*)_ps_1);
|
||||||
|
|
||||||
/* Evaluate the second polynom (Pi/4 <= x <= 0) */
|
/* Evaluate the second polynom (Pi/4 <= x <= 0) */
|
||||||
|
|
||||||
v4sf y2 = *(v4sf*)_ps_sincof_p0;
|
v4sf y2 = *(v4sf*)_ps_sincof_p0;
|
||||||
|
|
@ -696,7 +696,7 @@ void sincos_ps(v4sf x, v4sf *s, v4sf *c) {
|
||||||
y2 = _mm_mul_ps(y2, x);
|
y2 = _mm_mul_ps(y2, x);
|
||||||
y2 = _mm_add_ps(y2, x);
|
y2 = _mm_add_ps(y2, x);
|
||||||
|
|
||||||
/* select the correct result from the two polynoms */
|
/* select the correct result from the two polynoms */
|
||||||
xmm3 = poly_mask;
|
xmm3 = poly_mask;
|
||||||
v4sf ysin2 = _mm_and_ps(xmm3, y2);
|
v4sf ysin2 = _mm_and_ps(xmm3, y2);
|
||||||
v4sf ysin1 = _mm_andnot_ps(xmm3, y);
|
v4sf ysin1 = _mm_andnot_ps(xmm3, y);
|
||||||
|
|
@ -705,7 +705,7 @@ void sincos_ps(v4sf x, v4sf *s, v4sf *c) {
|
||||||
|
|
||||||
xmm1 = _mm_add_ps(ysin1,ysin2);
|
xmm1 = _mm_add_ps(ysin1,ysin2);
|
||||||
xmm2 = _mm_add_ps(y,y2);
|
xmm2 = _mm_add_ps(y,y2);
|
||||||
|
|
||||||
/* update the sign */
|
/* update the sign */
|
||||||
*s = _mm_xor_ps(xmm1, sign_bit_sin);
|
*s = _mm_xor_ps(xmm1, sign_bit_sin);
|
||||||
*c = _mm_xor_ps(xmm2, sign_bit_cos);
|
*c = _mm_xor_ps(xmm2, sign_bit_cos);
|
||||||
|
|
|
||||||
|
|
@ -70,7 +70,7 @@ Type ADSREnvelope<Type>::getNextValue() noexcept
|
||||||
return start;
|
return start;
|
||||||
|
|
||||||
currentState = State::Attack;
|
currentState = State::Attack;
|
||||||
step = (1.0 - currentValue) / (attack > 0 ? attack : 1);
|
step = (static_cast<Type>(1.0) - currentValue) / (attack > 0 ? attack : 1);
|
||||||
[[fallthrough]];
|
[[fallthrough]];
|
||||||
case State::Attack:
|
case State::Attack:
|
||||||
if (attack-- > 0) {
|
if (attack-- > 0) {
|
||||||
|
|
|
||||||
|
|
@ -68,6 +68,21 @@ public:
|
||||||
bytes.fetch_sub(size);
|
bytes.fetch_sub(size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void bufferDeleted(size_t size)
|
||||||
|
{
|
||||||
|
bufferDeleted(static_cast<int>(size));
|
||||||
|
}
|
||||||
|
|
||||||
|
void bufferResized(size_t oldSize, size_t newSize)
|
||||||
|
{
|
||||||
|
bufferResized(static_cast<int>(oldSize), static_cast<int>(newSize));
|
||||||
|
}
|
||||||
|
|
||||||
|
void newBuffer(size_t size)
|
||||||
|
{
|
||||||
|
newBuffer(static_cast<int>(size));
|
||||||
|
}
|
||||||
|
|
||||||
int getNumBuffers() { return numBuffers; }
|
int getNumBuffers() { return numBuffers; }
|
||||||
int getTotalBytes() { return bytes; }
|
int getTotalBytes() { return bytes; }
|
||||||
private:
|
private:
|
||||||
|
|
@ -165,7 +180,7 @@ public:
|
||||||
*/
|
*/
|
||||||
void clear()
|
void clear()
|
||||||
{
|
{
|
||||||
counter().bufferResized(largerSize * sizeof(value_type), 0);
|
counter().bufferResized(largerSize * sizeof(value_type), static_cast<size_t>(0));
|
||||||
largerSize = 0;
|
largerSize = 0;
|
||||||
alignedSize = 0;
|
alignedSize = 0;
|
||||||
std::free(paddedData);
|
std::free(paddedData);
|
||||||
|
|
|
||||||
|
|
@ -73,7 +73,7 @@ void EventEnvelope<Type>::prepareEvents()
|
||||||
absl::c_sort(events, [](const auto& lhs, const auto& rhs) {
|
absl::c_sort(events, [](const auto& lhs, const auto& rhs) {
|
||||||
return lhs.first < rhs.first;
|
return lhs.first < rhs.first;
|
||||||
});
|
});
|
||||||
|
|
||||||
resetEvents = true;
|
resetEvents = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -134,7 +134,7 @@ void LinearEnvelope<Type>::getQuantizedBlock(absl::Span<Type> output, Type quant
|
||||||
EventEnvelope<Type>::getQuantizedBlock(output, quantizationStep);
|
EventEnvelope<Type>::getQuantizedBlock(output, quantizationStep);
|
||||||
auto& events = EventEnvelope<Type>::events;
|
auto& events = EventEnvelope<Type>::events;
|
||||||
auto& currentValue = EventEnvelope<Type>::currentValue;
|
auto& currentValue = EventEnvelope<Type>::currentValue;
|
||||||
|
|
||||||
ASSERT(quantizationStep != 0.0);
|
ASSERT(quantizationStep != 0.0);
|
||||||
int index { 0 };
|
int index { 0 };
|
||||||
|
|
||||||
|
|
@ -167,7 +167,7 @@ void LinearEnvelope<Type>::getQuantizedBlock(absl::Span<Type> output, Type quant
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const int numSteps = difference / quantizationStep;
|
const auto numSteps = static_cast<int>(difference / quantizationStep);
|
||||||
const auto stepLength = static_cast<int>(length / numSteps);
|
const auto stepLength = static_cast<int>(length / numSteps);
|
||||||
for (int i = 0; i < numSteps; ++i) {
|
for (int i = 0; i < numSteps; ++i) {
|
||||||
fill<Type>(output.subspan(index, stepLength), currentValue);
|
fill<Type>(output.subspan(index, stepLength), currentValue);
|
||||||
|
|
@ -218,15 +218,15 @@ void MultiplicativeEnvelope<Type>::getQuantizedBlock(absl::Span<Type> output, Ty
|
||||||
EventEnvelope<Type>::getQuantizedBlock(output, quantizationStep);
|
EventEnvelope<Type>::getQuantizedBlock(output, quantizationStep);
|
||||||
auto& events = EventEnvelope<Type>::events;
|
auto& events = EventEnvelope<Type>::events;
|
||||||
auto& currentValue = EventEnvelope<Type>::currentValue;
|
auto& currentValue = EventEnvelope<Type>::currentValue;
|
||||||
|
|
||||||
ASSERT(quantizationStep != 0.0);
|
ASSERT(quantizationStep != 0.0);
|
||||||
int index { 0 };
|
int index { 0 };
|
||||||
|
|
||||||
const auto logStep = std::log(quantizationStep);
|
const auto logStep = std::log(quantizationStep);
|
||||||
// If we assume that a = b.q^r for b in (1, q) then
|
// If we assume that a = b.q^r for b in (1, q) then
|
||||||
// log a log b
|
// log a log b
|
||||||
// ----- = ----- + r
|
// ----- = ----- + r
|
||||||
// log q log q
|
// log q log q
|
||||||
// and log(b)\log(q) is between 0 and 1.
|
// and log(b)\log(q) is between 0 and 1.
|
||||||
auto quantize = [logStep](Type value) -> Type {
|
auto quantize = [logStep](Type value) -> Type {
|
||||||
return std::exp(logStep * std::round(std::log(value)/logStep));
|
return std::exp(logStep * std::round(std::log(value)/logStep));
|
||||||
|
|
@ -257,11 +257,11 @@ void MultiplicativeEnvelope<Type>::getQuantizedBlock(absl::Span<Type> output, Ty
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const int numSteps = std::log(difference) / logStep;
|
const auto numSteps = static_cast<int>(std::log(difference) / logStep);
|
||||||
const auto stepLength = static_cast<int>(length / numSteps);
|
const auto stepLength = static_cast<int>(length / numSteps);
|
||||||
for (int i = 0; i < numSteps; ++i) {
|
for (int i = 0; i < numSteps; ++i) {
|
||||||
fill<Type>(output.subspan(index, stepLength), currentValue);
|
fill<Type>(output.subspan(index, stepLength), currentValue);
|
||||||
const auto delta = newValue > currentValue ?
|
const auto delta = newValue > currentValue ?
|
||||||
quantize(currentValue) / currentValue * quantizationStep :
|
quantize(currentValue) / currentValue * quantizationStep :
|
||||||
quantize(currentValue) / currentValue / quantizationStep ;
|
quantize(currentValue) / currentValue / quantizationStep ;
|
||||||
currentValue *= delta;
|
currentValue *= delta;
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@
|
||||||
* @date 2019-11-23
|
* @date 2019-11-23
|
||||||
*/
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
#include "Config.h"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
|
@ -156,14 +157,14 @@ constexpr ValueType linearInterpolation(ValueType left, ValueType right, ValueTy
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class Type>
|
template <class Type>
|
||||||
constexpr Type pi { 3.141592653589793238462643383279502884 };
|
constexpr Type pi { static_cast<Type>(3.141592653589793238462643383279502884) };
|
||||||
template <class Type>
|
template <class Type>
|
||||||
constexpr Type twoPi { 2 * pi<Type> };
|
constexpr Type twoPi { static_cast<Type>(2) * pi<Type> };
|
||||||
template <class Type>
|
template <class Type>
|
||||||
constexpr Type piTwo { pi<Type> / 2 };
|
constexpr Type piTwo { pi<Type> / static_cast<Type>(2) };
|
||||||
template <class Type>
|
template <class Type>
|
||||||
constexpr Type piFour { pi<Type> / 4 };
|
constexpr Type piFour { pi<Type> / static_cast<Type>(4) };
|
||||||
template <class Type>
|
template <class Type>
|
||||||
constexpr Type sqrtTwo { 1.414213562373095048801688724209698078569671875376948073176 };
|
constexpr Type sqrtTwo { static_cast<Type>(1.414213562373095048801688724209698078569671875376948073176) };
|
||||||
template <class Type>
|
template <class Type>
|
||||||
constexpr Type sqrtTwoInv { 0.707106781186547524400844362104849039284835937688474036588 };
|
constexpr Type sqrtTwoInv { static_cast<Type>(0.707106781186547524400844362104849039284835937688474036588) };
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,6 @@
|
||||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
#include "Parser.h"
|
#include "Parser.h"
|
||||||
#include "Config.h"
|
|
||||||
#include "StringViewHelpers.h"
|
#include "StringViewHelpers.h"
|
||||||
#include "SfzHelpers.h"
|
#include "SfzHelpers.h"
|
||||||
#include "absl/strings/str_join.h"
|
#include "absl/strings/str_join.h"
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@
|
||||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
#include "Config.h"
|
||||||
#include "Opcode.h"
|
#include "Opcode.h"
|
||||||
#include "ghc/fs_std.hpp"
|
#include "ghc/fs_std.hpp"
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue