28 using namespace folly;
31 #if !defined(__clang__) && !defined(_MSC_VER) 34 static_assert(
nextPowTwo(2u) == 2,
"nextPowTwo");
38 static_assert(
isPowTwo(2u),
"isPowTwo");
48 for (
size_t i = 0;
i < bits;
i++) {
49 INT
v = (
static_cast<INT
>(1) << (bits - 1)) | (static_cast<INT>(1) <<
i);
58 size_t bits = std::numeric_limits<UINT_T>::digits;
59 for (
size_t i = 0;
i < bits;
i++) {
60 INT v1 =
static_cast<UINT_T
>(1) <<
i;
63 INT v2 = (
static_cast<UINT_T
>(1) <<
i) - 1;
72 testFFS<signed char>();
73 testFFS<unsigned char>();
75 testFFS<unsigned short>();
77 testFFS<unsigned int>();
79 testFFS<unsigned long>();
81 testFFS<unsigned long long>();
86 testFLS<signed char>();
87 testFLS<unsigned char>();
89 testFLS<unsigned short>();
91 testFLS<unsigned int>();
93 testFLS<unsigned long>();
95 testFLS<unsigned long long>();
183 auto f = std::uniform_real_distribution<float>()(rng);
186 auto d = std::uniform_real_distribution<double>()(rng);
194 for (
int i = 0;
i < 64;
i++) {
203 EXPECT_EQ(folly::bitReverse<uint8_t>(0), 0);
204 EXPECT_EQ(folly::bitReverse<uint8_t>(1), 128);
205 for (
int i = 0;
i < 100;
i++) {
214 std::vector<char> buf(128);
217 for (
size_t l = 0; l < 8; ++l) {
218 for (
size_t pos = 0; pos <= buf.size() - l; ++pos) {
219 auto p = buf.data() + pos;
220 auto x = folly::partialLoadUnaligned<uint64_t>(p, l);
223 memcpy(&expected, p, l);
228 auto x32 = folly::partialLoadUnaligned<uint32_t>(p, l);
229 EXPECT_EQ(x32, static_cast<uint32_t>(expected));
constexpr unsigned int popcount(T const v)
constexpr T nextPowTwo(T const v)
BitIterator< BaseIter > findFirstSet(BitIterator< BaseIter >, BitIterator< BaseIter >)
#define EXPECT_EQ(val1, val2)
uint64_t reverse_simple(uint64_t v)
—— Concurrent Priority Queue Implementation ——
constexpr bool isPowTwo(T const v)
constexpr T prevPowTwo(T const v)
constexpr unsigned int findLastSet(T const v)
#define EXPECT_TRUE(condition)
#define EXPECT_NE(val1, val2)
#define EXPECT_FALSE(condition)
TEST(SequencedExecutor, CPUThreadPoolExecutor)