GNU Radio 3.6.5 C++ API

volk_64u_popcnt_a.h

Go to the documentation of this file.
00001 #ifndef INCLUDED_volk_64u_popcnt_a_H
00002 #define INCLUDED_volk_64u_popcnt_a_H
00003 
00004 #include <stdio.h>
00005 #include <inttypes.h>
00006 
00007 
00008 #ifdef LV_HAVE_GENERIC
00009 
00010 
00011 static inline void volk_64u_popcnt_a_generic(uint64_t* ret, const uint64_t value) {
00012 
00013   //const uint32_t* valueVector = (const uint32_t*)&value;
00014 
00015   // This is faster than a lookup table
00016   //uint32_t retVal = valueVector[0];
00017   uint32_t retVal = (uint32_t)(value & 0x00000000FFFFFFFF);
00018 
00019   retVal = (retVal & 0x55555555) + (retVal >> 1 & 0x55555555);
00020   retVal = (retVal & 0x33333333) + (retVal >> 2 & 0x33333333);
00021   retVal = (retVal + (retVal >> 4)) & 0x0F0F0F0F;
00022   retVal = (retVal + (retVal >> 8));
00023   retVal = (retVal + (retVal >> 16)) & 0x0000003F;
00024   uint64_t retVal64  = retVal;
00025 
00026   //retVal = valueVector[1];
00027   retVal = (uint32_t)((value & 0xFFFFFFFF00000000) >> 31);
00028   retVal = (retVal & 0x55555555) + (retVal >> 1 & 0x55555555);
00029   retVal = (retVal & 0x33333333) + (retVal >> 2 & 0x33333333);
00030   retVal = (retVal + (retVal >> 4)) & 0x0F0F0F0F;
00031   retVal = (retVal + (retVal >> 8));
00032   retVal = (retVal + (retVal >> 16)) & 0x0000003F;
00033   retVal64 += retVal;
00034 
00035   *ret = retVal64;
00036 
00037 }
00038 
00039 #endif /*LV_HAVE_GENERIC*/
00040 
00041 #if LV_HAVE_SSE4_2 && LV_HAVE_64
00042 
00043 #include <nmmintrin.h>
00044 
00045 static inline void volk_64u_popcnt_a_sse4_2(uint64_t* ret, const uint64_t value) {
00046   *ret = _mm_popcnt_u64(value);
00047 
00048 }
00049 
00050 #endif /*LV_HAVE_SSE4_2*/
00051 
00052 #endif /*INCLUDED_volk_64u_popcnt_a_H*/