FreeRDP
Loading...
Searching...
No Matches
prim_add_neon.c
1
19
20#include <freerdp/config.h>
21
22#include <freerdp/types.h>
23#include <freerdp/primitives.h>
24#include <winpr/sysinfo.h>
25
26#include "prim_internal.h"
27#include "prim_add.h"
28
29#if defined(NEON_INTRINSICS_ENABLED)
30#include <arm_neon.h>
31
32static primitives_t* generic = nullptr;
33
34static pstatus_t neon_add_16s_inplace(INT16* WINPR_RESTRICT pSrcDst1,
35 INT16* WINPR_RESTRICT pSrcDst2, UINT32 ulen)
36{
37 INT16* dptr1 = pSrcDst1;
38 INT16* dptr2 = pSrcDst2;
39 size_t len = ulen;
40
41 /* Use 2 128-bit NEON registers. */
42 size_t count = len >> 4;
43 len -= count << 4;
44 while (count--)
45 {
46 const int16x8_t a0 = vld1q_s16(dptr1);
47 const int16x8_t a1 = vld1q_s16(dptr1 + 8);
48 const int16x8_t b0 = vld1q_s16(dptr2);
49 const int16x8_t b1 = vld1q_s16(dptr2 + 8);
50 const int16x8_t sum0 = vqaddq_s16(a0, b0);
51 const int16x8_t sum1 = vqaddq_s16(a1, b1);
52
53 vst1q_s16(dptr1, sum0);
54 vst1q_s16(dptr1 + 8, sum1);
55 vst1q_s16(dptr2, sum0);
56 vst1q_s16(dptr2 + 8, sum1);
57
58 dptr1 += 16;
59 dptr2 += 16;
60 }
61 /* Finish off the remainder. */
62 if (len > 0)
63 return generic->add_16s_inplace(dptr1, dptr2, WINPR_ASSERTING_INT_CAST(uint32_t, len));
64
65 return PRIMITIVES_SUCCESS;
66}
67#endif
68
69/* ------------------------------------------------------------------------- */
70void primitives_init_add_neon_int(primitives_t* WINPR_RESTRICT prims)
71{
72#if defined(NEON_INTRINSICS_ENABLED)
73 generic = primitives_get_generic();
74
75 WLog_VRB(PRIM_TAG, "NEON optimizations");
76 prims->add_16s_inplace = neon_add_16s_inplace;
77#else
78 WLog_VRB(PRIM_TAG, "undefined WITH_SIMD or neon intrinsics not available");
79 WINPR_UNUSED(prims);
80#endif
81}
WINPR_ATTR_NODISCARD fn_add_16s_inplace_t add_16s_inplace
Do vecotor addition, store result in both input buffers pSrcDst1 = pSrcDst2 = pSrcDst1 + pSrcDst2.
Definition primitives.h:302