19 #include <glog/logging.h> 23 using namespace folly;
26 TEST(Instructions, BitExtraction) {
28 0b11111110
'11011100'10111010
'10011000'01110110
'01010100'00110010
'00010000; 30 if (not Haswell::supported()) { 34 LOG(INFO) << "Testing Haswell on supported machine"; 36 // Extract 4 bits a time, starting from bit 0 37 uint64_t expected = 0; 38 for (int i = 0; i < 64 - 4; i += 4) { 39 EXPECT_EQ(expected, Default::bextr(value, i, 4)); 40 EXPECT_EQ(expected, Haswell::bextr(value, i, 4)); 44 // Extract 8 bits a time, starting from bit 1 45 uint64_t value2 = value << 1; 48 for (int i = 1; i < 64 - 8; i += 4) { 49 expected = (lower & 0xF) | ((upper & 0xF) << 4); 50 EXPECT_EQ(expected, Default::bextr(value2, i, 8)); 51 EXPECT_EQ(expected, Haswell::bextr(value2, i, 8)); 56 // Extract 16 bits a time, starting from bit 2 57 uint64_t value3 = value << 2; 62 for (int i = 2; i < 64 - 16; i += 4) { 63 expected = (part0 & 0xF) | ((part1 & 0xF) << 4) | ((part2 & 0xF) << 8) | 64 ((part3 & 0xF) << 12); 65 EXPECT_EQ(expected, Default::bextr(value3, i, 16)); 66 EXPECT_EQ(expected, Haswell::bextr(value3, i, 16)); 74 expected = 0b1011'1010
'1001'1000
'0111'0110
'0101'0100;
#define EXPECT_EQ(val1, val2)
—— Concurrent Priority Queue Implementation ——
static FOLLY_ALWAYS_INLINE uint64_t bextr(uint64_t value, uint32_t start, uint32_t length)
uint64_t value(const typename LockFreeRingBuffer< T, Atom >::Cursor &rbcursor)
static FOLLY_ALWAYS_INLINE uint64_t bextr(uint64_t value, uint32_t start, uint32_t length)
TEST(SequencedExecutor, CPUThreadPoolExecutor)