aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/lib/pubkey/xmss/xmss_tools.cpp90
-rw-r--r--src/lib/pubkey/xmss/xmss_tools.h42
2 files changed, 0 insertions, 132 deletions
diff --git a/src/lib/pubkey/xmss/xmss_tools.cpp b/src/lib/pubkey/xmss/xmss_tools.cpp
deleted file mode 100644
index 585e14f2e..000000000
--- a/src/lib/pubkey/xmss/xmss_tools.cpp
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * XMSS Tools
- * (C) 2017 Matthias Gierlings
- *
- * Botan is released under the Simplified BSD License (see license.txt)
- **/
-
-#include <botan/xmss_tools.h>
-
-namespace Botan {
-
-#if defined(BOTAN_TARGET_OS_HAS_THREADS)
-
-size_t XMSS_Tools::max_threads()
- {
- static const size_t threads { bench_threads() };
- return threads;
- }
-
-size_t XMSS_Tools::bench_threads()
- {
- const size_t hardware_concurrency = std::thread::hardware_concurrency();
-
- if(hardware_concurrency <= 1)
- {
- return 1;
- }
- const size_t BENCH_ITERATIONS = 1000;
- std::vector<std::thread> threads;
- threads.reserve(hardware_concurrency);
- std::vector<std::chrono::nanoseconds> durations;
-
- std::vector<size_t> concurrency { hardware_concurrency,
- hardware_concurrency / 2 };
-
- for(const auto& cc : concurrency)
- {
- std::vector<XMSS_Hash> hash(hardware_concurrency,
- XMSS_Hash("SHA-256"));
-
- const std::vector<uint8_t> buffer(hash[0].output_length());
- std::vector<secure_vector<uint8_t>> data(
- hardware_concurrency,
- secure_vector<uint8_t>(hash[0].output_length()));
- auto start = std::chrono::high_resolution_clock::now();
- for(size_t i = 0; i < cc; ++i)
- {
- auto& hs = hash[i];
- auto& d = data[i];
-
- const size_t n_iters = BENCH_ITERATIONS * (hardware_concurrency / cc);
- threads.emplace_back(std::thread([n_iters, &hs, &d]()
- {
- for(size_t n = 0; n < n_iters; n++)
- {
- hs.h(d, d, d);
- }
- }
- ));
- }
- durations.emplace_back(std::chrono::duration_cast<std::chrono::nanoseconds>(std::chrono::high_resolution_clock::now() - start));
- for(auto& t : threads)
- {
- t.join();
- }
- threads.clear();
- }
-
- if(durations[0].count() < durations[1].count())
- {
-#if defined(BOTAN_TEST_MODE)
- return 4;
-#else
- return concurrency[0];
-#endif
- }
- else
- {
-#if defined(BOTAN_TEST_MODE)
- return 4;
-#else
- return concurrency[1];
-#endif
- }
- }
-
-#endif
-
-}
-
diff --git a/src/lib/pubkey/xmss/xmss_tools.h b/src/lib/pubkey/xmss/xmss_tools.h
index 65c4a83a7..bbd31fd9f 100644
--- a/src/lib/pubkey/xmss/xmss_tools.h
+++ b/src/lib/pubkey/xmss/xmss_tools.h
@@ -13,12 +13,6 @@
#include <iterator>
#include <type_traits>
-#if defined(BOTAN_TARGET_OS_HAS_THREADS)
- #include <thread>
- #include <chrono>
- #include <botan/xmss_hash.h>
-#endif
-
namespace Botan {
/**
@@ -59,44 +53,8 @@ class XMSS_Tools final
void>::type>
static void concat(secure_vector<uint8_t>& target, const T& src, size_t len);
- /**
- * Not a public API function - will be removed in a future release.
- *
- * Determines the maximum number of threads to be used
- * efficiently, based on runtime timining measurements. Ideally the
- * result will correspond to the physical number of cores. On systems
- * supporting simultaneous multi threading (SMT)
- * std::thread::hardware_concurrency() usually reports a supported
- * number of threads which is bigger (typically by a factor of 2) than
- * the number of physical cores available. Using more threads than
- * physically available cores for computationally intesive tasks
- * resulted in slowdowns compared to using a number of threads equal to
- * the number of physical cores on test systems. This function is a
- * temporary workaround to prevent performance degradation due to
- * overstressing the CPU with too many threads.
- *
- * @return Presumed number of physical cores based on timing measurements.
- **/
- static size_t max_threads(); // TODO: Remove max_threads() and use
- // Botan::CPUID once proper plattform
- // independent detection of physical cores is
- // available.
-
private:
XMSS_Tools();
- /**
- * Measures the time t1 it takes to calculate hashes using
- * std::thread::hardware_concurrency() many threads and the time t2
- * calculating the same number of hashes using
- * std::thread::hardware_concurrency() / 2 threads.
- *
- * @return std::thread::hardware_concurrency() if t1 < t2
- * std::thread::hardware_concurrency() / 2 otherwise.
- **/
- static size_t bench_threads(); // TODO: Remove bench_threads() and use
- // Botan::CPUID once proper plattform
- // independent detection of physical cores
- // is //available.
};
template <typename T, typename U>