Squashed 'src/minisketch/' changes from 47f0a2d26f..a571ba20f9

a571ba20f9 Merge sipa/minisketch#68: Add missed `#include <string>`
b9a7f7e2bc Merge sipa/minisketch#69: refactor: Drop unused `total` local variables
8a5af94edc Merge sipa/minisketch#70: build: Remove `-Qunused-arguments` workaround for clang + ccache
c36f1f03a3 Merge sipa/minisketch#72: Fix MSVC implementation of `CountBits()` function
0078bedda6 Ignore `HAVE_CLZ` macro when building with MSVC
1c772918c4 Fix MSVC implementation of `CountBits()` function
98f87c55f4 build: Remove `-Qunused-arguments` workaround for clang + ccache
11a1e25c81 refactor: Drop unused `total` local variables
ed6c8fcfd9 Add missed `#include <string>`

git-subtree-dir: src/minisketch
git-subtree-split: a571ba20f9dd1accab6a2309d066369878042ca6
pull/26373/head^2
Hennadii Stepanov 2 years ago
parent 28a28a0c5b
commit e9f1d8c272

@ -124,9 +124,6 @@ if test "x$use_ccache" != "xno"; then
fi
AC_MSG_RESULT($use_ccache)
fi
if test "x$use_ccache" = "xyes"; then
AX_CHECK_COMPILE_FLAG([-Qunused-arguments],[NOWARN_CXXFLAGS="$NOWARN_CXXFLAGS -Qunused-arguments"],,[[$CXXFLAG_WERROR]])
fi
VERIFY_DEFINES=-DMINISKETCH_VERIFY
RELEASE_DEFINES=

@ -62,13 +62,11 @@ int main(int argc, char** argv) {
if (!states[0]) {
printf(" -\t");
} else {
double total = 0.0;
for (auto& state : states) {
auto start = std::chrono::steady_clock::now();
minisketch_decode(state, 2 * syndromes, roots.data());
auto stop = std::chrono::steady_clock::now();
std::chrono::duration<double> dur(stop - start);
total += dur.count();
benches.push_back(dur.count());
}
std::sort(benches.begin(), benches.end());
@ -98,7 +96,6 @@ int main(int argc, char** argv) {
if (!states[0]) {
printf(" -\t");
} else {
double total = 0.0;
for (auto& state : states) {
auto start = std::chrono::steady_clock::now();
for (auto val : data) {
@ -106,7 +103,6 @@ int main(int argc, char** argv) {
}
auto stop = std::chrono::steady_clock::now();
std::chrono::duration<double> dur(stop - start);
total += dur.count();
benches.push_back(dur.count());
}
std::sort(benches.begin(), benches.end());

@ -129,17 +129,7 @@ constexpr inline I Mask() { return ((I((I(-1)) << (std::numeric_limits<I>::digit
/** Compute the smallest power of two that is larger than val. */
template<typename I>
static inline int CountBits(I val, int max) {
#ifdef HAVE_CLZ
(void)max;
if (val == 0) return 0;
if (std::numeric_limits<unsigned>::digits >= std::numeric_limits<I>::digits) {
return std::numeric_limits<unsigned>::digits - __builtin_clz(val);
} else if (std::numeric_limits<unsigned long>::digits >= std::numeric_limits<I>::digits) {
return std::numeric_limits<unsigned long>::digits - __builtin_clzl(val);
} else {
return std::numeric_limits<unsigned long long>::digits - __builtin_clzll(val);
}
#elif _MSC_VER
#ifdef _MSC_VER
(void)max;
unsigned long index;
unsigned char ret;
@ -149,7 +139,17 @@ static inline int CountBits(I val, int max) {
ret = _BitScanReverse64(&index, val);
}
if (!ret) return 0;
return index;
return index + 1;
#elif HAVE_CLZ
(void)max;
if (val == 0) return 0;
if (std::numeric_limits<unsigned>::digits >= std::numeric_limits<I>::digits) {
return std::numeric_limits<unsigned>::digits - __builtin_clz(val);
} else if (std::numeric_limits<unsigned long>::digits >= std::numeric_limits<I>::digits) {
return std::numeric_limits<unsigned long>::digits - __builtin_clzl(val);
} else {
return std::numeric_limits<unsigned long long>::digits - __builtin_clzll(val);
}
#else
while (max && (val >> (max - 1) == 0)) --max;
return max;

@ -9,6 +9,7 @@
#include <limits>
#include <random>
#include <stdexcept>
#include <string>
#include <vector>
#include "../include/minisketch.h"

Loading…
Cancel
Save