// (C) Copyright Nick Thompson 2020. // Use, modification and distribution are subject to the // Boost Software License, Version 1.0. (See accompanying file // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) #include #include #include #include #include #include using boost::multiprecision::number; using boost::multiprecision::mpfr_float_backend; using boost::multiprecision::float128; using boost::multiprecision::cpp_bin_float_50; using boost::multiprecision::cpp_bin_float_100; using boost::math::rsqrt; template void Rsqrt(benchmark::State& state) { std::random_device rd; std::mt19937_64 mt(rd()); std::uniform_real_distribution unif(1,100); Real x = static_cast(unif(mt)); for (auto _ : state) { benchmark::DoNotOptimize(rsqrt(x)); x += std::numeric_limits::epsilon(); } } BENCHMARK_TEMPLATE(Rsqrt, float); BENCHMARK_TEMPLATE(Rsqrt, double); BENCHMARK_TEMPLATE(Rsqrt, long double); BENCHMARK_TEMPLATE(Rsqrt, float128); BENCHMARK_TEMPLATE(Rsqrt, number>); BENCHMARK_TEMPLATE(Rsqrt, number>); BENCHMARK_TEMPLATE(Rsqrt, number>); BENCHMARK_TEMPLATE(Rsqrt, number>); BENCHMARK_TEMPLATE(Rsqrt, number>); BENCHMARK_TEMPLATE(Rsqrt, cpp_bin_float_50); BENCHMARK_TEMPLATE(Rsqrt, cpp_bin_float_100); BENCHMARK_MAIN();