File: simd_softclip_benchmarks.cpp

package info (click to toggle)
supercollider-sc3-plugins 3.9.1~repack-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye
  • size: 13,444 kB
  • sloc: cpp: 150,202; lisp: 7,004; ansic: 3,547; makefile: 86; haskell: 21; sh: 8
file content (62 lines) | stat: -rw-r--r-- 1,588 bytes parent folder | download | duplicates (13)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include "benchmark_helpers.hpp"
#include "cache_aligned_array.hpp"
#include "../softclip.hpp"

using namespace nova;
using namespace std;

aligned_array<float, 64> out, args_best_case, args_worst_case, args_avg_case;

void __noinline__ bench_simd_best(unsigned int n)
{
    softclip_vec_simd(out.begin(), args_best_case.begin(), n);
}

void __noinline__ bench_best(unsigned int n)
{
    softclip_vec(out.begin(), args_best_case.begin(), n);
}

void __noinline__ bench_simd_worst(unsigned int n)
{
    softclip_vec_simd(out.begin(), args_worst_case.begin(), n);
}

void __noinline__ bench_worst(unsigned int n)
{
    softclip_vec(out.begin(), args_worst_case.begin(), n);
}

void __noinline__ bench_simd_avg(unsigned int n)
{
    softclip_vec_simd(out.begin(), args_avg_case.begin(), n);
}

void __noinline__ bench_avg(unsigned int n)
{
    softclip_vec(out.begin(), args_avg_case.begin(), n);
}

int main(void)
{
    out.assign(0.f);

    const unsigned int iterations = 10000000;

    for (int i = 0; i != 64; ++i)
    {
        args_best_case[i] = float(i) / 128.0;
        args_worst_case[i] = float(i) / 64.0 + 0.5;
        args_avg_case[i] = float(i) / 64.0;
    }

    cout << "simd:" << endl;
    run_bench(boost::bind(bench_simd_best, 64), iterations);
    run_bench(boost::bind(bench_simd_avg, 64), iterations);
    run_bench(boost::bind(bench_simd_worst, 64), iterations);

    cout << "\nnormal:" << endl;
    run_bench(boost::bind(bench_best, 64), iterations);
    run_bench(boost::bind(bench_avg, 64), iterations);
    run_bench(boost::bind(bench_worst, 64), iterations);
}