Skip to content

Commit

Permalink
Squashed 'src/minisketch/' changes from 47f0a2d26f..a571ba20f9
Browse files Browse the repository at this point in the history
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
  • Loading branch information
hebasto committed Oct 23, 2022
1 parent 28a28a0 commit e9f1d8c
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 19 deletions.
3 changes: 0 additions & 3 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
4 changes: 0 additions & 4 deletions src/bench.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down Expand Up @@ -98,15 +96,13 @@ 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) {
minisketch_add_uint64(state, val);
}
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());
Expand Down
24 changes: 12 additions & 12 deletions src/int_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
1 change: 1 addition & 0 deletions src/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <limits>
#include <random>
#include <stdexcept>
#include <string>
#include <vector>

#include "../include/minisketch.h"
Expand Down

0 comments on commit e9f1d8c

Please sign in to comment.