Vector Optimized Library of Kernels 3.2.0
Architecture-tuned implementations of math kernels
Loading...
Searching...
No Matches
volk_16i_max_star_16i.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 VOLK
6 *
7 * SPDX-License-Identifier: LGPL-3.0-or-later
8 */
9
43
44#ifndef INCLUDED_volk_16i_max_star_16i_a_H
45#define INCLUDED_volk_16i_max_star_16i_a_H
46
47#include <inttypes.h>
48#include <stdio.h>
49
50#ifdef LV_HAVE_SSSE3
51
52#include <emmintrin.h>
53#include <tmmintrin.h>
54#include <xmmintrin.h>
55
56static inline void
57volk_16i_max_star_16i_a_ssse3(short* target, short* src0, unsigned int num_points)
58{
59 const unsigned int num_bytes = num_points * 2;
60
61 short candidate = src0[0];
62 short cands[8];
63 __m128i xmm0, xmm1, xmm3, xmm4, xmm5, xmm6;
64
65 __m128i* p_src0;
66
67 p_src0 = (__m128i*)src0;
68
69 int bound = num_bytes >> 4;
70 int leftovers = (num_bytes >> 1) & 7;
71
72 int i = 0;
73
74 xmm1 = _mm_setzero_si128();
75 xmm0 = _mm_setzero_si128();
76 //_mm_insert_epi16(xmm0, candidate, 0);
77
78 xmm0 = _mm_shuffle_epi8(xmm0, xmm1);
79
80 for (i = 0; i < bound; ++i) {
81 xmm1 = _mm_load_si128(p_src0);
82 p_src0 += 1;
83 // xmm2 = _mm_sub_epi16(xmm1, xmm0);
84
85 xmm3 = _mm_cmpgt_epi16(xmm0, xmm1);
86 xmm4 = _mm_cmpeq_epi16(xmm0, xmm1);
87 xmm5 = _mm_cmpgt_epi16(xmm1, xmm0);
88
89 xmm6 = _mm_xor_si128(xmm4, xmm5);
90
91 xmm3 = _mm_and_si128(xmm3, xmm0);
92 xmm4 = _mm_and_si128(xmm6, xmm1);
93
94 xmm0 = _mm_add_epi16(xmm3, xmm4);
95 }
96
97 _mm_store_si128((__m128i*)cands, xmm0);
98
99 for (i = 0; i < 8; ++i) {
100 candidate = ((short)(candidate - cands[i]) > 0) ? candidate : cands[i];
101 }
102
103 for (i = 0; i < leftovers; ++i) {
104 candidate = ((short)(candidate - src0[(bound << 3) + i]) > 0)
105 ? candidate
106 : src0[(bound << 3) + i];
107 }
108
109 target[0] = candidate;
110}
111
112#endif /*LV_HAVE_SSSE3*/
113
114#ifdef LV_HAVE_GENERIC
115
116static inline void
117volk_16i_max_star_16i_generic(short* target, short* src0, unsigned int num_points)
118{
119 const unsigned int num_bytes = num_points * 2;
120
121 int i = 0;
122
123 int bound = num_bytes >> 1;
124
125 short candidate = src0[0];
126 for (i = 1; i < bound; ++i) {
127 candidate = ((short)(candidate - src0[i]) > 0) ? candidate : src0[i];
128 }
129 target[0] = candidate;
130}
131
132#endif /*LV_HAVE_GENERIC*/
133
134
135#endif /*INCLUDED_volk_16i_max_star_16i_a_H*/
static void volk_16i_max_star_16i_a_ssse3(short *target, short *src0, unsigned int num_points)
Definition volk_16i_max_star_16i.h:57
static void volk_16i_max_star_16i_generic(short *target, short *src0, unsigned int num_points)
Definition volk_16i_max_star_16i.h:117
for i
Definition volk_config_fixed.tmpl.h:13