summaryrefslogtreecommitdiff
path: root/volk/include/volk/volk_64u_popcnt_a.h
diff options
context:
space:
mode:
authorTom Rondeau2011-08-27 16:44:32 -0400
committerTom Rondeau2011-08-27 16:44:32 -0400
commit54881f8803d4f796dde2af031e6f1a37df9445f1 (patch)
treeb1e4e6c34004f22a29c03815ed3ae49065693dce /volk/include/volk/volk_64u_popcnt_a.h
parent50cde24aea52d66d69313a490f7eab78a5085849 (diff)
parentf4cc7884c608a7ec1969e68b73e12cdbcc26145c (diff)
downloadgnuradio-54881f8803d4f796dde2af031e6f1a37df9445f1.tar.gz
gnuradio-54881f8803d4f796dde2af031e6f1a37df9445f1.tar.bz2
gnuradio-54881f8803d4f796dde2af031e6f1a37df9445f1.zip
Merge branch 'master' of gnuradio.org:gnuradio
Diffstat (limited to 'volk/include/volk/volk_64u_popcnt_a.h')
-rw-r--r--volk/include/volk/volk_64u_popcnt_a.h50
1 files changed, 50 insertions, 0 deletions
diff --git a/volk/include/volk/volk_64u_popcnt_a.h b/volk/include/volk/volk_64u_popcnt_a.h
new file mode 100644
index 000000000..bdaa98643
--- /dev/null
+++ b/volk/include/volk/volk_64u_popcnt_a.h
@@ -0,0 +1,50 @@
+#ifndef INCLUDED_volk_64u_popcnt_a_H
+#define INCLUDED_volk_64u_popcnt_a_H
+
+#include <stdio.h>
+#include <inttypes.h>
+
+
+#ifdef LV_HAVE_GENERIC
+
+
+static inline void volk_64u_popcnt_a_generic(uint64_t* ret, const uint64_t value) {
+
+ const uint32_t* valueVector = (const uint32_t*)&value;
+
+ // This is faster than a lookup table
+ uint32_t retVal = valueVector[0];
+
+ retVal = (retVal & 0x55555555) + (retVal >> 1 & 0x55555555);
+ retVal = (retVal & 0x33333333) + (retVal >> 2 & 0x33333333);
+ retVal = (retVal + (retVal >> 4)) & 0x0F0F0F0F;
+ retVal = (retVal + (retVal >> 8));
+ retVal = (retVal + (retVal >> 16)) & 0x0000003F;
+ uint64_t retVal64 = retVal;
+
+ retVal = valueVector[1];
+ retVal = (retVal & 0x55555555) + (retVal >> 1 & 0x55555555);
+ retVal = (retVal & 0x33333333) + (retVal >> 2 & 0x33333333);
+ retVal = (retVal + (retVal >> 4)) & 0x0F0F0F0F;
+ retVal = (retVal + (retVal >> 8));
+ retVal = (retVal + (retVal >> 16)) & 0x0000003F;
+ retVal64 += retVal;
+
+ *ret = retVal64;
+
+}
+
+#endif /*LV_HAVE_GENERIC*/
+
+#if LV_HAVE_SSE4_2 && LV_HAVE_64
+
+#include <nmmintrin.h>
+
+static inline void volk_64u_popcnt_a_sse4_2(uint64_t* ret, const uint64_t value) {
+ *ret = _mm_popcnt_u64(value);
+
+}
+
+#endif /*LV_HAVE_SSE4_2*/
+
+#endif /*INCLUDED_volk_64u_popcnt_a_H*/