blob: 72449468ef483f1503ae48283e280f4c7ea7d0c8 [file] [log] [blame]
Eric3afc1d12020-07-23 02:16:46 +02001/*! \file conv_acc_neon.c
2 * Accelerated Viterbi decoder implementation
3 * for architectures with only NEON available. */
4/*
5 * (C) 2020 by sysmocom - s.f.m.c. GmbH
6 * Author: Eric Wild
7 *
8 * All Rights Reserved
9 *
10 * SPDX-License-Identifier: GPL-2.0+
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License along
23 * with this program; if not, write to the Free Software Foundation, Inc.,
24 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 */
26
27#include <stdlib.h>
28#include <stdint.h>
29#include <malloc.h>
30#include "config.h"
31
32#if defined(HAVE_NEON)
33#include <arm_neon.h>
34#endif
35
36/* align req is 16 on android because google was confused, 8 on sane platforms */
37#define NEON_ALIGN 8
38
39#include <conv_acc_neon_impl.h>
40
41/* Aligned Memory Allocator
42 * NEON requires 8-byte memory alignment. We store relevant trellis values
43 * (accumulated sums, outputs, and path decisions) as 16 bit signed integers
44 * so the allocated memory is casted as such.
45 */
46__attribute__ ((visibility("hidden")))
47int16_t *osmo_conv_neon_vdec_malloc(size_t n)
48{
49 return (int16_t *) memalign(NEON_ALIGN, sizeof(int16_t) * n);
50}
51
52__attribute__ ((visibility("hidden")))
53void osmo_conv_neon_vdec_free(int16_t *ptr)
54{
55 free(ptr);
56}
57
58__attribute__ ((visibility("hidden")))
59void osmo_conv_neon_metrics_k5_n2(const int8_t *val, const int16_t *out,
60 int16_t *sums, int16_t *paths, int norm)
61{
62 const int16_t _val[4] = { val[0], val[1], val[0], val[1] };
63
64 _neon_metrics_k5_n2(_val, out, sums, paths, norm);
65}
66
67__attribute__ ((visibility("hidden")))
68void osmo_conv_neon_metrics_k5_n3(const int8_t *val, const int16_t *out,
69 int16_t *sums, int16_t *paths, int norm)
70{
71 const int16_t _val[4] = { val[0], val[1], val[2], 0 };
72
73 _neon_metrics_k5_n4(_val, out, sums, paths, norm);
74}
75
76__attribute__ ((visibility("hidden")))
77void osmo_conv_neon_metrics_k5_n4(const int8_t *val, const int16_t *out,
78 int16_t *sums, int16_t *paths, int norm)
79{
80 const int16_t _val[4] = { val[0], val[1], val[2], val[3] };
81
82 _neon_metrics_k5_n4(_val, out, sums, paths, norm);
83}
84
85__attribute__ ((visibility("hidden")))
86void osmo_conv_neon_metrics_k7_n2(const int8_t *val, const int16_t *out,
87 int16_t *sums, int16_t *paths, int norm)
88{
89 const int16_t _val[4] = { val[0], val[1], val[0], val[1] };
90
91 _neon_metrics_k7_n2(_val, out, sums, paths, norm);
92}
93
94__attribute__ ((visibility("hidden")))
95void osmo_conv_neon_metrics_k7_n3(const int8_t *val, const int16_t *out,
96 int16_t *sums, int16_t *paths, int norm)
97{
98 const int16_t _val[4] = { val[0], val[1], val[2], 0 };
99
100 _neon_metrics_k7_n4(_val, out, sums, paths, norm);
101}
102
103__attribute__ ((visibility("hidden")))
104void osmo_conv_neon_metrics_k7_n4(const int8_t *val, const int16_t *out,
105 int16_t *sums, int16_t *paths, int norm)
106{
107 const int16_t _val[4] = { val[0], val[1], val[2], val[3] };
108
109 _neon_metrics_k7_n4(_val, out, sums, paths, norm);
110}