GCC Code Coverage Report


Directory: ./
File: kernels/volk/volk_64f_x2_min_64f.h
Date: 2023-10-23 23:10:04
Exec Total Coverage
Lines: 67 105 63.8%
Functions: 4 6 66.7%
Branches: 21 34 61.8%

Line Branch Exec Source
1 /* -*- c++ -*- */
2 /*
3 * Copyright 2012, 2014 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 /*!
11 * \page volk_64f_x2_min_64f
12 *
13 * \b Overview
14 *
15 * Selects minimum value from each entry between bVector and aVector
16 * and store their results in the cVector.
17 *
18 * c[i] = min(a[i], b[i])
19 *
20 * <b>Dispatcher Prototype</b>
21 * \code
22 * void volk_64f_x2_min_64f(double* cVector, const double* aVector, const double* bVector,
23 unsigned int num_points)
24 * \endcode
25 *
26 * \b Inputs
27 * \li aVector: First input vector.
28 * \li bVector: Second input vector.
29 * \li num_points: The number of values in both input vectors.
30 *
31 * \b Outputs
32 * \li cVector: The output vector.
33 *
34 * \b Example
35 * \code
36 int N = 10;
37 unsigned int alignment = volk_get_alignment();
38 double* increasing = (double*)volk_malloc(sizeof(double)*N, alignment);
39 double* decreasing = (double*)volk_malloc(sizeof(double)*N, alignment);
40 double* out = (double*)volk_malloc(sizeof(double)*N, alignment);
41
42 for(unsigned int ii = 0; ii < N; ++ii){
43 increasing[ii] = (double)ii;
44 decreasing[ii] = 10.f - (double)ii;
45 }
46
47 volk_64f_x2_min_64f(out, increasing, decreasing, N);
48
49 for(unsigned int ii = 0; ii < N; ++ii){
50 printf("out[%u] = %1.2g\n", ii, out[ii]);
51 }
52
53 volk_free(increasing);
54 volk_free(decreasing);
55 volk_free(out);
56 * \endcode
57 */
58
59 #ifndef INCLUDED_volk_64f_x2_min_64f_a_H
60 #define INCLUDED_volk_64f_x2_min_64f_a_H
61
62 #include <inttypes.h>
63 #include <stdio.h>
64
65 #ifdef LV_HAVE_AVX512F
66 #include <immintrin.h>
67
68 static inline void volk_64f_x2_min_64f_a_avx512f(double* cVector,
69 const double* aVector,
70 const double* bVector,
71 unsigned int num_points)
72 {
73 unsigned int number = 0;
74 const unsigned int eigthPoints = num_points / 8;
75
76 double* cPtr = cVector;
77 const double* aPtr = aVector;
78 const double* bPtr = bVector;
79
80 __m512d aVal, bVal, cVal;
81 for (; number < eigthPoints; number++) {
82
83 aVal = _mm512_load_pd(aPtr);
84 bVal = _mm512_load_pd(bPtr);
85
86 cVal = _mm512_min_pd(aVal, bVal);
87
88 _mm512_store_pd(cPtr, cVal); // Store the results back into the C container
89
90 aPtr += 8;
91 bPtr += 8;
92 cPtr += 8;
93 }
94
95 number = eigthPoints * 8;
96 for (; number < num_points; number++) {
97 const double a = *aPtr++;
98 const double b = *bPtr++;
99 *cPtr++ = (a < b ? a : b);
100 }
101 }
102 #endif /* LV_HAVE_AVX512F */
103
104
105 #ifdef LV_HAVE_AVX
106 #include <immintrin.h>
107
108 2 static inline void volk_64f_x2_min_64f_a_avx(double* cVector,
109 const double* aVector,
110 const double* bVector,
111 unsigned int num_points)
112 {
113 2 unsigned int number = 0;
114 2 const unsigned int quarterPoints = num_points / 4;
115
116 2 double* cPtr = cVector;
117 2 const double* aPtr = aVector;
118 2 const double* bPtr = bVector;
119
120 __m256d aVal, bVal, cVal;
121
2/2
✓ Branch 0 taken 65534 times.
✓ Branch 1 taken 2 times.
65536 for (; number < quarterPoints; number++) {
122
123 65534 aVal = _mm256_load_pd(aPtr);
124 65534 bVal = _mm256_load_pd(bPtr);
125
126 65534 cVal = _mm256_min_pd(aVal, bVal);
127
128 _mm256_store_pd(cPtr, cVal); // Store the results back into the C container
129
130 65534 aPtr += 4;
131 65534 bPtr += 4;
132 65534 cPtr += 4;
133 }
134
135 2 number = quarterPoints * 4;
136
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 2 times.
8 for (; number < num_points; number++) {
137 6 const double a = *aPtr++;
138 6 const double b = *bPtr++;
139
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 3 times.
6 *cPtr++ = (a < b ? a : b);
140 }
141 2 }
142 #endif /* LV_HAVE_AVX */
143
144
145 #ifdef LV_HAVE_SSE2
146 #include <emmintrin.h>
147
148 2 static inline void volk_64f_x2_min_64f_a_sse2(double* cVector,
149 const double* aVector,
150 const double* bVector,
151 unsigned int num_points)
152 {
153 2 unsigned int number = 0;
154 2 const unsigned int halfPoints = num_points / 2;
155
156 2 double* cPtr = cVector;
157 2 const double* aPtr = aVector;
158 2 const double* bPtr = bVector;
159
160 __m128d aVal, bVal, cVal;
161
2/2
✓ Branch 0 taken 131070 times.
✓ Branch 1 taken 2 times.
131072 for (; number < halfPoints; number++) {
162
163 131070 aVal = _mm_load_pd(aPtr);
164 131070 bVal = _mm_load_pd(bPtr);
165
166 131070 cVal = _mm_min_pd(aVal, bVal);
167
168 _mm_store_pd(cPtr, cVal); // Store the results back into the C container
169
170 131070 aPtr += 2;
171 131070 bPtr += 2;
172 131070 cPtr += 2;
173 }
174
175 2 number = halfPoints * 2;
176
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2 times.
4 for (; number < num_points; number++) {
177 2 const double a = *aPtr++;
178 2 const double b = *bPtr++;
179
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 *cPtr++ = (a < b ? a : b);
180 }
181 2 }
182 #endif /* LV_HAVE_SSE2 */
183
184
185 #ifdef LV_HAVE_GENERIC
186
187 2 static inline void volk_64f_x2_min_64f_generic(double* cVector,
188 const double* aVector,
189 const double* bVector,
190 unsigned int num_points)
191 {
192 2 double* cPtr = cVector;
193 2 const double* aPtr = aVector;
194 2 const double* bPtr = bVector;
195 2 unsigned int number = 0;
196
197
2/2
✓ Branch 0 taken 262142 times.
✓ Branch 1 taken 2 times.
262144 for (number = 0; number < num_points; number++) {
198 262142 const double a = *aPtr++;
199 262142 const double b = *bPtr++;
200
2/2
✓ Branch 0 taken 131324 times.
✓ Branch 1 taken 130818 times.
262142 *cPtr++ = (a < b ? a : b);
201 }
202 2 }
203 #endif /* LV_HAVE_GENERIC */
204
205
206 #endif /* INCLUDED_volk_64f_x2_min_64f_a_H */
207
208 #ifndef INCLUDED_volk_64f_x2_min_64f_u_H
209 #define INCLUDED_volk_64f_x2_min_64f_u_H
210
211 #include <inttypes.h>
212 #include <stdio.h>
213
214 #ifdef LV_HAVE_AVX512F
215 #include <immintrin.h>
216
217 static inline void volk_64f_x2_min_64f_u_avx512f(double* cVector,
218 const double* aVector,
219 const double* bVector,
220 unsigned int num_points)
221 {
222 unsigned int number = 0;
223 const unsigned int eigthPoints = num_points / 8;
224
225 double* cPtr = cVector;
226 const double* aPtr = aVector;
227 const double* bPtr = bVector;
228
229 __m512d aVal, bVal, cVal;
230 for (; number < eigthPoints; number++) {
231
232 aVal = _mm512_loadu_pd(aPtr);
233 bVal = _mm512_loadu_pd(bPtr);
234
235 cVal = _mm512_min_pd(aVal, bVal);
236
237 _mm512_storeu_pd(cPtr, cVal); // Store the results back into the C container
238
239 aPtr += 8;
240 bPtr += 8;
241 cPtr += 8;
242 }
243
244 number = eigthPoints * 8;
245 for (; number < num_points; number++) {
246 const double a = *aPtr++;
247 const double b = *bPtr++;
248 *cPtr++ = (a < b ? a : b);
249 }
250 }
251 #endif /* LV_HAVE_AVX512F */
252
253
254 #ifdef LV_HAVE_AVX
255 #include <immintrin.h>
256
257 2 static inline void volk_64f_x2_min_64f_u_avx(double* cVector,
258 const double* aVector,
259 const double* bVector,
260 unsigned int num_points)
261 {
262 2 unsigned int number = 0;
263 2 const unsigned int quarterPoints = num_points / 4;
264
265 2 double* cPtr = cVector;
266 2 const double* aPtr = aVector;
267 2 const double* bPtr = bVector;
268
269 __m256d aVal, bVal, cVal;
270
2/2
✓ Branch 0 taken 65534 times.
✓ Branch 1 taken 2 times.
65536 for (; number < quarterPoints; number++) {
271
272 65534 aVal = _mm256_loadu_pd(aPtr);
273 65534 bVal = _mm256_loadu_pd(bPtr);
274
275 65534 cVal = _mm256_min_pd(aVal, bVal);
276
277 _mm256_storeu_pd(cPtr, cVal); // Store the results back into the C container
278
279 65534 aPtr += 4;
280 65534 bPtr += 4;
281 65534 cPtr += 4;
282 }
283
284 2 number = quarterPoints * 4;
285
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 2 times.
8 for (; number < num_points; number++) {
286 6 const double a = *aPtr++;
287 6 const double b = *bPtr++;
288
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 3 times.
6 *cPtr++ = (a < b ? a : b);
289 }
290 2 }
291 #endif /* LV_HAVE_AVX */
292
293
294 #endif /* INCLUDED_volk_64f_x2_min_64f_u_H */
295