#include <iostream>
#include "benchmark/benchmark.h"
#include "type_name.hpp"
#include <Eigen/Core>
#include <duals/dual>
#define N_RANGE ->RangeMultiplier(8)->Range(2, 1<<13)
template <class Rt> void B_Add(benchmark::State& state) {
int N = state.range(0);
std::vector<Rt> a(N);
std::vector<Rt> b(N);
std::vector<Rt> c(N);
for (auto _ : state) {
for (int i = 0; i < N; i++)
a[i] = b[i] + c[i];
benchmark::ClobberMemory();
}
}
template <class Rt> void B_Sub(benchmark::State& state) {
int N = state.range(0);
std::vector<Rt> a(N);
std::vector<Rt> b(N);
std::vector<Rt> c(N);
for (auto _ : state) {
for (int i = 0; i < N; i++)
a[i] = b[i] - c[i];
benchmark::ClobberMemory();
}
}
template <class Rt> void B_Mul(benchmark::State& state) {
int N = state.range(0);
std::vector<Rt> a(N);
std::vector<Rt> b(N);
std::vector<Rt> c(N);
for (auto _ : state) {
for (int i = 0; i < N; i++)
a[i] = b[i] * c[i];
benchmark::ClobberMemory();
}
}
template <class Rt> void B_Div(benchmark::State& state) {
int N = state.range(0);
std::vector<Rt> a(N);
std::vector<Rt> b(N);
std::vector<Rt> c(N);
for (auto _ : state) {
for (int i = 0; i < N; i++)
a[i] = b[i] / c[i];
benchmark::ClobberMemory();
}
}
BENCHMARK_TEMPLATE(B_Add, duals::dualf) N_RANGE;
BENCHMARK_TEMPLATE(B_Add, std::complex<float>) N_RANGE;
BENCHMARK_TEMPLATE(B_Sub, duals::dualf) N_RANGE;
BENCHMARK_TEMPLATE(B_Sub, std::complex<float>) N_RANGE;
BENCHMARK_TEMPLATE(B_Mul, duals::dualf) N_RANGE;
BENCHMARK_TEMPLATE(B_Mul, std::complex<float>) N_RANGE;
BENCHMARK_TEMPLATE(B_Div, duals::dualf) N_RANGE;
BENCHMARK_TEMPLATE(B_Div, std::complex<float>) N_RANGE;
#define QUOTE(...) STRFY(__VA_ARGS__)
#define STRFY(...) #__VA_ARGS__
int main(int argc, char** argv)
{
std::cout << "OPT_FLAGS=" << QUOTE(OPT_FLAGS) << "\n";
std::cout << "INSTRUCTIONSET=" << Eigen::SimdInstructionSetsInUse() << "\n";
::benchmark::Initialize(&argc, argv);
::benchmark::RunSpecifiedBenchmarks();
}