From 4f4250d0a8029f9954898e1b1b1908ee1ce2de30 Mon Sep 17 00:00:00 2001 From: Jack Lloyd Date: Thu, 18 May 2017 11:48:00 -0400 Subject: Add ability to clear cpuid bits before running benchmarks. Should be extended further, and some duplicated logic with the tests here, but useful as is. [ci skip] --- src/cli/speed.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'src/cli/speed.cpp') diff --git a/src/cli/speed.cpp b/src/cli/speed.cpp index cf048e0d2..30a01a934 100644 --- a/src/cli/speed.cpp +++ b/src/cli/speed.cpp @@ -415,7 +415,7 @@ class Speed final : public Command { public: Speed() - : Command("speed --msec=300 --provider= --buf-size=4096 *algos") {} + : Command("speed --msec=300 --provider= --buf-size=4096 --clear-cpuid= *algos") {} void go() override { @@ -424,6 +424,19 @@ class Speed final : public Command const std::string provider = get_arg("provider"); std::vector algos = get_arg_list("algos"); + + Botan::CPUID::initialize(); + + for(std::string cpuid_to_clear : Botan::split_on(get_arg("clear-cpuid"), ',')) + { +#if defined(BOTAN_TARGET_CPU_IS_X86_FAMILY) + if(cpuid_to_clear == "avx2") + Botan::CPUID::clear_cpuid_bit(Botan::CPUID::CPUID_AVX2_BIT); + else if(cpuid_to_clear == "sse2") + Botan::CPUID::clear_cpuid_bit(Botan::CPUID::CPUID_SSE2_BIT); +#endif + } + const bool using_defaults = (algos.empty()); if(using_defaults) { -- cgit v1.2.3