GNU Radio 3.7.2 C++ API
volk_32u_popcnt.h
Go to the documentation of this file.
1 #ifndef INCLUDED_VOLK_32u_POPCNT_A16_H
2 #define INCLUDED_VOLK_32u_POPCNT_A16_H
3 
4 #include <stdio.h>
5 #include <inttypes.h>
6 
7 
8 #ifdef LV_HAVE_GENERIC
9 
10 static inline void volk_32u_popcnt_generic(uint32_t* ret, const uint32_t value) {
11 
12  // This is faster than a lookup table
13  uint32_t retVal = value;
14 
15  retVal = (retVal & 0x55555555) + (retVal >> 1 & 0x55555555);
16  retVal = (retVal & 0x33333333) + (retVal >> 2 & 0x33333333);
17  retVal = (retVal + (retVal >> 4)) & 0x0F0F0F0F;
18  retVal = (retVal + (retVal >> 8));
19  retVal = (retVal + (retVal >> 16)) & 0x0000003F;
20 
21  *ret = retVal;
22 }
23 
24 #endif /*LV_HAVE_GENERIC*/
25 
26 #ifdef LV_HAVE_SSE4_2
27 
28 #include <nmmintrin.h>
29 
30 static inline void volk_32u_popcnt_a_sse4_2(uint32_t* ret, const uint32_t value) {
31  *ret = _mm_popcnt_u32(value);
32 }
33 
34 #endif /*LV_HAVE_SSE4_2*/
35 
36 #endif /*INCLUDED_VOLK_32u_POPCNT_A16_H*/
unsigned int uint32_t
Definition: stdint.h:80