GNU Radio Manual and C++ API Reference  3.7.4
The Free & Open Software Radio Ecosystem
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
volk_64u_popcnt.h
Go to the documentation of this file.
1 #ifndef INCLUDED_volk_64u_popcnt_a_H
2 #define INCLUDED_volk_64u_popcnt_a_H
3 
4 #include <stdio.h>
5 #include <inttypes.h>
6 
7 
8 #ifdef LV_HAVE_GENERIC
9 
10 
11 static inline void volk_64u_popcnt_generic(uint64_t* ret, const uint64_t value) {
12 
13  //const uint32_t* valueVector = (const uint32_t*)&value;
14 
15  // This is faster than a lookup table
16  //uint32_t retVal = valueVector[0];
17  uint32_t retVal = (uint32_t)(value & 0x00000000FFFFFFFF);
18 
19  retVal = (retVal & 0x55555555) + (retVal >> 1 & 0x55555555);
20  retVal = (retVal & 0x33333333) + (retVal >> 2 & 0x33333333);
21  retVal = (retVal + (retVal >> 4)) & 0x0F0F0F0F;
22  retVal = (retVal + (retVal >> 8));
23  retVal = (retVal + (retVal >> 16)) & 0x0000003F;
24  uint64_t retVal64 = retVal;
25 
26  //retVal = valueVector[1];
27  retVal = (uint32_t)((value & 0xFFFFFFFF00000000) >> 31);
28  retVal = (retVal & 0x55555555) + (retVal >> 1 & 0x55555555);
29  retVal = (retVal & 0x33333333) + (retVal >> 2 & 0x33333333);
30  retVal = (retVal + (retVal >> 4)) & 0x0F0F0F0F;
31  retVal = (retVal + (retVal >> 8));
32  retVal = (retVal + (retVal >> 16)) & 0x0000003F;
33  retVal64 += retVal;
34 
35  *ret = retVal64;
36 
37 }
38 
39 #endif /*LV_HAVE_GENERIC*/
40 
41 #if LV_HAVE_SSE4_2 && LV_HAVE_64
42 
43 #include <nmmintrin.h>
44 
45 static inline void volk_64u_popcnt_a_sse4_2(uint64_t* ret, const uint64_t value) {
46  *ret = _mm_popcnt_u64(value);
47 
48 }
49 
50 #endif /*LV_HAVE_SSE4_2*/
51 
52 #endif /*INCLUDED_volk_64u_popcnt_a_H*/
unsigned int uint32_t
Definition: stdint.h:80
unsigned __int64 uint64_t
Definition: stdint.h:90