Vector Optimized Library of Kernels  3.0.0
Architecture-tuned implementations of math kernels
volk_8u_x3_encodepolarpuppet_8u.h
Go to the documentation of this file.
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2015 Free Software Foundation, Inc.
4  *
5  * This file is part of VOLK
6  *
7  * SPDX-License-Identifier: LGPL-3.0-or-later
8  */
9 
10 /* For documentation see 'kernels/volk/volk_8u_x3_encodepolar_8u_x2.h'
11  * This file exists for test purposes only. Should not be used directly.
12  */
13 
14 #ifndef VOLK_KERNELS_VOLK_VOLK_8U_X3_ENCODEPOLARPUPPET_8U_H_
15 #define VOLK_KERNELS_VOLK_VOLK_8U_X3_ENCODEPOLARPUPPET_8U_H_
16 #include <volk/volk.h>
18 
19 static inline unsigned int next_lower_power_of_two(const unsigned int val)
20 {
21  // algorithm found and adopted from:
22  // http://acius2.blogspot.de/2007/11/calculating-next-power-of-2.html
23  unsigned int res = val;
24  res = (res >> 1) | res;
25  res = (res >> 2) | res;
26  res = (res >> 4) | res;
27  res = (res >> 8) | res;
28  res = (res >> 16) | res;
29  res += 1;
30  return res >> 1;
31 }
32 
33 static inline void adjust_frozen_mask(unsigned char* mask, const unsigned int frame_size)
34 {
35  // just like the rest of the puppet this function exists for test purposes only.
36  unsigned int i;
37  for (i = 0; i < frame_size; ++i) {
38  *mask = (*mask & 0x80) ? 0xFF : 0x00;
39  mask++;
40  }
41 }
42 
43 #ifdef LV_HAVE_GENERIC
44 static inline void
46  unsigned char* frozen_bit_mask,
47  const unsigned char* frozen_bits,
48  const unsigned char* info_bits,
49  unsigned int frame_size)
50 {
51  frame_size = next_lower_power_of_two(frame_size);
52  unsigned char* temp = (unsigned char*)volk_malloc(sizeof(unsigned char) * frame_size,
54  adjust_frozen_mask(frozen_bit_mask, frame_size);
56  frame, temp, frozen_bit_mask, frozen_bits, info_bits, frame_size);
57  volk_free(temp);
58 }
59 #endif /* LV_HAVE_GENERIC */
60 
61 
62 #ifdef LV_HAVE_SSSE3
63 static inline void
65  unsigned char* frozen_bit_mask,
66  const unsigned char* frozen_bits,
67  const unsigned char* info_bits,
68  unsigned int frame_size)
69 {
70  frame_size = next_lower_power_of_two(frame_size);
71  unsigned char* temp = (unsigned char*)volk_malloc(sizeof(unsigned char) * frame_size,
73  adjust_frozen_mask(frozen_bit_mask, frame_size);
75  frame, temp, frozen_bit_mask, frozen_bits, info_bits, frame_size);
76  volk_free(temp);
77 }
78 #endif /* LV_HAVE_SSSE3 */
79 
80 #ifdef LV_HAVE_AVX2
81 static inline void
82 volk_8u_x3_encodepolarpuppet_8u_u_avx2(unsigned char* frame,
83  unsigned char* frozen_bit_mask,
84  const unsigned char* frozen_bits,
85  const unsigned char* info_bits,
86  unsigned int frame_size)
87 {
88  frame_size = next_lower_power_of_two(frame_size);
89  unsigned char* temp = (unsigned char*)volk_malloc(sizeof(unsigned char) * frame_size,
91  adjust_frozen_mask(frozen_bit_mask, frame_size);
92  volk_8u_x3_encodepolar_8u_x2_u_avx2(
93  frame, temp, frozen_bit_mask, frozen_bits, info_bits, frame_size);
94  volk_free(temp);
95 }
96 #endif /* LV_HAVE_AVX2 */
97 
98 #endif /* VOLK_KERNELS_VOLK_VOLK_8U_X3_ENCODEPOLARPUPPET_8U_H_ */
99 
100 #ifndef VOLK_KERNELS_VOLK_VOLK_8U_X3_ENCODEPOLARPUPPET_8U_A_H_
101 #define VOLK_KERNELS_VOLK_VOLK_8U_X3_ENCODEPOLARPUPPET_8U_A_H_
102 
103 #ifdef LV_HAVE_SSSE3
104 static inline void
106  unsigned char* frozen_bit_mask,
107  const unsigned char* frozen_bits,
108  const unsigned char* info_bits,
109  unsigned int frame_size)
110 {
111  frame_size = next_lower_power_of_two(frame_size);
112  unsigned char* temp = (unsigned char*)volk_malloc(sizeof(unsigned char) * frame_size,
114  adjust_frozen_mask(frozen_bit_mask, frame_size);
116  frame, temp, frozen_bit_mask, frozen_bits, info_bits, frame_size);
117  volk_free(temp);
118 }
119 #endif /* LV_HAVE_SSSE3 */
120 
121 #ifdef LV_HAVE_AVX2
122 static inline void
123 volk_8u_x3_encodepolarpuppet_8u_a_avx2(unsigned char* frame,
124  unsigned char* frozen_bit_mask,
125  const unsigned char* frozen_bits,
126  const unsigned char* info_bits,
127  unsigned int frame_size)
128 {
129  frame_size = next_lower_power_of_two(frame_size);
130  unsigned char* temp = (unsigned char*)volk_malloc(sizeof(unsigned char) * frame_size,
132  adjust_frozen_mask(frozen_bit_mask, frame_size);
133  volk_8u_x3_encodepolar_8u_x2_a_avx2(
134  frame, temp, frozen_bit_mask, frozen_bits, info_bits, frame_size);
135  volk_free(temp);
136 }
137 #endif /* LV_HAVE_AVX2 */
138 
139 
140 #endif /* VOLK_KERNELS_VOLK_VOLK_8U_X3_ENCODEPOLARPUPPET_8U_A_H_ */
val
Definition: volk_arch_defs.py:57
size_t volk_get_alignment(void)
Get the machine alignment in bytes.
Definition: volk.tmpl.c:90
static void volk_8u_x3_encodepolar_8u_x2_generic(unsigned char *frame, unsigned char *temp, const unsigned char *frozen_bit_mask, const unsigned char *frozen_bits, const unsigned char *info_bits, unsigned int frame_size)
Definition: volk_8u_x3_encodepolar_8u_x2.h:85
static void volk_8u_x3_encodepolar_8u_x2_a_ssse3(unsigned char *frame, unsigned char *temp, const unsigned char *frozen_bit_mask, const unsigned char *frozen_bits, const unsigned char *info_bits, unsigned int frame_size)
Definition: volk_8u_x3_encodepolar_8u_x2.h:143
static void volk_8u_x3_encodepolar_8u_x2_u_ssse3(unsigned char *frame, unsigned char *temp, const unsigned char *frozen_bit_mask, const unsigned char *frozen_bits, const unsigned char *info_bits, unsigned int frame_size)
Definition: volk_8u_x3_encodepolar_8u_x2.h:104
static void adjust_frozen_mask(unsigned char *mask, const unsigned int frame_size)
Definition: volk_8u_x3_encodepolarpuppet_8u.h:33
static unsigned int next_lower_power_of_two(const unsigned int val)
Definition: volk_8u_x3_encodepolarpuppet_8u.h:19
static void volk_8u_x3_encodepolarpuppet_8u_generic(unsigned char *frame, unsigned char *frozen_bit_mask, const unsigned char *frozen_bits, const unsigned char *info_bits, unsigned int frame_size)
Definition: volk_8u_x3_encodepolarpuppet_8u.h:45
static void volk_8u_x3_encodepolarpuppet_8u_a_ssse3(unsigned char *frame, unsigned char *frozen_bit_mask, const unsigned char *frozen_bits, const unsigned char *info_bits, unsigned int frame_size)
Definition: volk_8u_x3_encodepolarpuppet_8u.h:105
static void volk_8u_x3_encodepolarpuppet_8u_u_ssse3(unsigned char *frame, unsigned char *frozen_bit_mask, const unsigned char *frozen_bits, const unsigned char *info_bits, unsigned int frame_size)
Definition: volk_8u_x3_encodepolarpuppet_8u.h:64
for i
Definition: volk_config_fixed.tmpl.h:13
__VOLK_DECL_BEGIN VOLK_API void * volk_malloc(size_t size, size_t alignment)
Allocate size bytes of data aligned to alignment.
Definition: volk_malloc.c:38
VOLK_API void volk_free(void *aptr)
Free's memory allocated by volk_malloc.
Definition: volk_malloc.c:80