Vector Optimized Library of Kernels 2.5.1
Architecture-tuned implementations of math kernels
 
Loading...
Searching...
No Matches
volk_32u_popcnt.h
Go to the documentation of this file.
1/* -*- c++ -*- */
2/*
3 * Copyright 2012, 2014 Free Software Foundation, Inc.
4 *
5 * This file is part of GNU Radio
6 *
7 * GNU Radio is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3, or (at your option)
10 * any later version.
11 *
12 * GNU Radio is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with GNU Radio; see the file COPYING. If not, write to
19 * the Free Software Foundation, Inc., 51 Franklin Street,
20 * Boston, MA 02110-1301, USA.
21 */
22
56#ifndef INCLUDED_VOLK_32u_POPCNT_A16_H
57#define INCLUDED_VOLK_32u_POPCNT_A16_H
58
59#include <inttypes.h>
60#include <stdio.h>
61
62#ifdef LV_HAVE_GENERIC
63
64static inline void volk_32u_popcnt_generic(uint32_t* ret, const uint32_t value)
65{
66 // This is faster than a lookup table
67 uint32_t retVal = value;
68
69 retVal = (retVal & 0x55555555) + (retVal >> 1 & 0x55555555);
70 retVal = (retVal & 0x33333333) + (retVal >> 2 & 0x33333333);
71 retVal = (retVal + (retVal >> 4)) & 0x0F0F0F0F;
72 retVal = (retVal + (retVal >> 8));
73 retVal = (retVal + (retVal >> 16)) & 0x0000003F;
74
75 *ret = retVal;
76}
77
78#endif /*LV_HAVE_GENERIC*/
79
80
81#ifdef LV_HAVE_SSE4_2
82
83#include <nmmintrin.h>
84
85static inline void volk_32u_popcnt_a_sse4_2(uint32_t* ret, const uint32_t value)
86{
87 *ret = _mm_popcnt_u32(value);
88}
89
90#endif /*LV_HAVE_SSE4_2*/
91
92#endif /*INCLUDED_VOLK_32u_POPCNT_A16_H*/
static void volk_32u_popcnt_a_sse4_2(uint32_t *ret, const uint32_t value)
Definition: volk_32u_popcnt.h:85
static void volk_32u_popcnt_generic(uint32_t *ret, const uint32_t value)
Definition: volk_32u_popcnt.h:64