Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Typedefs | Functions
QMath.h File Reference
#include <cassert>
#include <cstdint>

Go to the source code of this file.

Typedefs

template<int N, typename T >
using V = T __attribute__((ext_vector_type(N)))
 
using Q15 = V< 8, uint16_t >
 
using I16 = V< 8, int16_t >
 
using U16 = V< 8, uint16_t >
 

Functions

static U16 constrained_add (I16 a, U16 b)
 
static I16 simulate_ssse3_mm_mulhrs_epi16 (I16 a, I16 b)
 
static Q15 simulate_neon_vqrdmulhq_s16 (Q15 a, Q15 b)
 

Typedef Documentation

◆ I16

using I16 = V<8, int16_t>

Definition at line 30 of file QMath.h.

◆ Q15

using Q15 = V<8, uint16_t>

Definition at line 29 of file QMath.h.

◆ U16

using U16 = V<8, uint16_t>

Definition at line 31 of file QMath.h.

◆ V

template<int N, typename T >
using V = T __attribute__((ext_vector_type(N)))

Definition at line 11 of file QMath.h.

Function Documentation

◆ constrained_add()

static U16 constrained_add ( I16  a,
U16  b 
)
inlinestatic

Definition at line 34 of file QMath.h.

34 {
35for (size_t i = 0; i < 8; i++) {
36 // Ensure that a + b is on the interval [0, UINT16_MAX]
37 assert(-b[i] <= a[i] && a[i] <= UINT16_MAX - b[i]);
38}
39 U16 answer = b + a;
40 return answer;
41}
V< 8, uint16_t > U16
Definition QMath.h:31
static bool b
struct MyStruct a[10]

◆ simulate_neon_vqrdmulhq_s16()

static Q15 simulate_neon_vqrdmulhq_s16 ( Q15  a,
Q15  b 
)
inlinestatic

Definition at line 58 of file QMath.h.

58 {
59 Q15 result;
60 const int esize = 16;
61 auto m = [](int16_t r, int16_t s) {
62 const int64_t rounding = 1 << (esize - 1);
63 int64_t product = 2LL * (int64_t)r * (int64_t)s + rounding;
64 int64_t result = product >> esize;
65
66 // Saturate the result
67 if (int64_t limit = (1LL << (esize - 1)) - 1; result > limit) { result = limit; }
68 if (int64_t limit = -(1LL << (esize - 1)) ; result < limit) { result = limit; }
69 return result;
70 };
71 for (int i = 0; i < 8; i++) {
72 result[i] = m(a[i], b[i]);
73 }
74 return result;
75}
struct MyStruct s
GAsyncResult * result
V< 8, uint16_t > Q15

◆ simulate_ssse3_mm_mulhrs_epi16()

static I16 simulate_ssse3_mm_mulhrs_epi16 ( I16  a,
I16  b 
)
inlinestatic

Definition at line 44 of file QMath.h.

44 {
45 I16 result;
46 auto m = [](int16_t r, int16_t s) {
47 const int32_t rounding = 1 << 14;
48 int32_t temp = (int32_t)r * (int32_t)s + rounding;
49 return (int16_t)(temp >> 15);
50 };
51 for (int i = 0; i < 8; i++) {
52 result[i] = m(a[i], b[i]);
53 }
54 return result;
55}
V< 8, int16_t > I16
Definition QMath.h:30