summaryrefslogtreecommitdiffstats
path: root/patches/opus-1.5.1/0004-Add-OPUS_ARM_INLINE_DOTPROD-dotprod-check.patch
blob: 30590fb63c4bf12bb36189ef85d625abf3ec52f7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
From: Rudi Heitbaum <rudi@heitbaum.com>
Date: Sat, 9 Mar 2024 18:55:53 +0000
Subject: [PATCH] Add OPUS_ARM_INLINE_DOTPROD dotprod check

fixes:
  ../meson.build:322:9: ERROR: Unknown variable "opus_arm_may_have_dotprod"

after:
  dotprod check passes through.

Checking if "compiler supports gcc-style inline assembly" compiles: YES
Checking if "assembler supports EDSP instructions on ARM" compiles: YES
Checking if "assembler supports ARMv6 media instructions on ARM" compiles: YES
Checking if "assembler supports NEON instructions on ARM" compiles: YES
Checking if "assembler supports DOTPROD instructions on ARM" compiles: NO
Program perl found: YES (/usr/bin/perl)
Fetching value of define "__APPLE__" : (undefined)
Checking if "compiler supports ARMv7/AArch64 NEON intrinsics" : links: YES
Checking if "compiler supports AArch64 NEON intrinsics" : links: NO
Checking if "compiler supports AArch64 NEON intrinsics with -mfpu=neon" : links: NO
Message: Compiler does not support AArch64 NEON intrinsics
Checking if "compiler supports AArch64 DOTPROD intrinsics" : links: NO
Checking if "compiler supports AArch64 DOTPROD intrinsics with -march=armv8.2-a+dotprod" : links: NO
Message: Compiler does not support AArch64 DOTPROD intrinsics

refer:
- https://community.arm.com/arm-community-blogs/b/tools-software-ides-blog/posts/exploring-the-arm-dot-product-instructions

test with:
armv7ve-none-linux-gnueabihf-gcc test.c
/tmp/cc02sooK.s: Assembler messages:
/tmp/cc02sooK.s:32: Error: bad instruction `udot v0.4s,v1.16b,v2.16b'

aarch64-none-linux-gnu-gcc test.c
/tmp/ccnVi9Ec.s: Assembler messages:
/tmp/ccnVi9Ec.s:12: Error: selected processor does not support `udot v0.4s,v1.16b,v2.16b'

aarch64-none-linux-gnu-gcc -march=armv8.2-a+dotprod test.c

Signed-off-by: Rudi Heitbaum <rudi@heitbaum.com>
Signed-off-by: Jean-Marc Valin <jmvalin@jmvalin.ca>
---
 meson.build | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/meson.build b/meson.build
index bd23744cadb1..8624f0c38a59 100644
--- a/meson.build
+++ b/meson.build
@@ -252,6 +252,13 @@ if not opt_asm.disabled()
         opus_conf.set('OPUS_ARM_INLINE_NEON', 1)
         inline_optimization += ['NEON']
       endif
+
+      # AS_ASM_ARM_DOTPROD
+      if cc.compiles(asm_tmpl.format('udot v0.4s,v1.16b,v2.16b'),
+                     name : 'assembler supports DOTPROD instructions on ARM')
+        opus_conf.set('OPUS_ARM_INLINE_DOTPROD', 1)
+        inline_optimization += ['DOTPROD']
+      endif
     endif
 
     # We need Perl to translate RVCT-syntax asm to gas syntax
@@ -273,6 +280,9 @@ if not opt_asm.disabled()
       opus_arm_may_have_neon = opus_conf.has('OPUS_ARM_INLINE_NEON')
       opus_arm_presume_neon = opus_arm_may_have_neon and opus_can_presume_simd
 
+      opus_arm_may_have_dotprod = opus_conf.has('OPUS_ARM_INLINE_DOTPROD')
+      opus_arm_presume_dotprod = opus_arm_may_have_dotprod and opus_can_presume_simd
+
       if not opt_rtcd.disabled()
         if not opus_arm_may_have_edsp
           message('Trying to force-enable armv5e EDSP instructions...')