<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Aptos;
panose-1:2 11 0 4 2 2 2 2 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
font-size:12.0pt;
font-family:"Aptos",sans-serif;}
pre
{mso-style-priority:99;
mso-style-link:"HTML Preformatted Char";
margin:0cm;
margin-bottom:.0001pt;
font-size:10.0pt;
font-family:"Courier New";}
span.EmailStyle19
{mso-style-type:personal-reply;
font-family:"Aptos",sans-serif;
color:windowtext;}
span.HTMLPreformattedChar
{mso-style-name:"HTML Preformatted Char";
mso-style-priority:99;
mso-style-link:"HTML Preformatted";
font-family:"Courier New";}
.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;
mso-ligatures:none;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
{page:WordSection1;}
--></style>
</head>
<body lang="EN-GB" link="#467886" vlink="#96607D" style="word-wrap:break-word">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;mso-fareast-language:EN-US">HI Chen,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;mso-fareast-language:EN-US">Thank you for reviewing these patches.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<pre><span style="font-size:11.0pt;font-family:"Aptos",sans-serif;mso-fareast-language:EN-US">></span>In my view, compiler option is not good idea, unroll these loop in manual are more better, it helpful us find out optimzie point and improve algorithm future.<o:p></o:p></pre>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New"">><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New"">>For example, split DCT into deep Even part (EE/EEE, etc) does not get good performance<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;mso-fareast-language:EN-US">This series is intended to be largely NFC and to simply silence compiler warnings for the AArch64 intrinsics files. We plan to push optimisation patches for DCT primitives after
this series.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;mso-fareast-language:EN-US">Many thanks,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;mso-fareast-language:EN-US">Hari<o:p></o:p></span></p>
<div id="mail-editor-reference-message-container">
<div>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal" style="margin-bottom:12.0pt"><b><span style="color:black">From:
</span></b><span style="color:black">x265-devel <x265-devel-bounces@videolan.org> on behalf of Hari Limaye <hari.limaye@arm.com><br>
<b>Date: </b>Tuesday, 20 August 2024 at 18:42<br>
<b>To: </b>x265-devel@videolan.org <x265-devel@videolan.org><br>
<b>Subject: </b>[x265] [PATCH 2/3] AArch64: Refactor loop unroll pragmas in dct primitives<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt"><span style="font-size:11.0pt">Make #pragma unroll directives portable for Clang and GCC, as currently<br>
GCC will simply ignore the unsupported directives.<br>
---<br>
source/common/aarch64/dct-prim.cpp | 36 ++++++++++++++++++------------<br>
1 file changed, 22 insertions(+), 14 deletions(-)<br>
<br>
diff --git a/source/common/aarch64/dct-prim.cpp b/source/common/aarch64/dct-prim.cpp<br>
index 416532e54..acc50d4f4 100644<br>
--- a/source/common/aarch64/dct-prim.cpp<br>
+++ b/source/common/aarch64/dct-prim.cpp<br>
@@ -5,6 +5,14 @@<br>
<br>
#include <arm_neon.h><br>
<br>
+#define X265_PRAGMA(text) _Pragma(#text)<br>
+#if defined(__clang__)<br>
+#define X265_PRAGMA_UNROLL(n) X265_PRAGMA(unroll(n))<br>
+#elif defined(__GNUC__)<br>
+#define X265_PRAGMA_UNROLL(n) X265_PRAGMA(GCC unroll (n))<br>
+#else<br>
+#define X265_PRAGMA_UNROLL(n)<br>
+#endif<br>
<br>
namespace<br>
{<br>
@@ -472,12 +480,12 @@ static void partialButterflyInverse16_neon(const int16_t *src, int16_t *orig_dst<br>
const int add = 1 << (shift - 1);<br>
<br>
<br>
-#pragma unroll(4)<br>
+X265_PRAGMA_UNROLL(4)<br>
for (j = 0; j < line; j += 4)<br>
{<br>
/* Utilizing symmetry properties to the maximum to minimize the number of multiplications */<br>
<br>
-#pragma unroll(2)<br>
+X265_PRAGMA_UNROLL(2)<br>
for (k = 0; k < 2; k++)<br>
{<br>
int32x4_t s;<br>
@@ -496,7 +504,7 @@ static void partialButterflyInverse16_neon(const int16_t *src, int16_t *orig_dst<br>
EE[3] = vsubq_s32(EEE[0] , EEO[0]);<br>
<br>
<br>
-#pragma unroll(1)<br>
+X265_PRAGMA_UNROLL(1)<br>
for (k = 0; k < 4; k += 4)<br>
{<br>
int32x4_t s[4];<br>
@@ -522,14 +530,14 @@ static void partialButterflyInverse16_neon(const int16_t *src, int16_t *orig_dst<br>
static const int32x4_t max = vdupq_n_s32(32767);<br>
const int32x4_t minus_shift = vdupq_n_s32(-shift);<br>
<br>
-#pragma unroll(4)<br>
+X265_PRAGMA_UNROLL(4)<br>
for (k = 0; k < 4; k++)<br>
{<br>
E[k] = vaddq_s32(EE[k] , EO[k]);<br>
E[k + 4] = vsubq_s32(EE[3 - k] , EO[3 - k]);<br>
}<br>
<br>
-#pragma unroll(2)<br>
+X265_PRAGMA_UNROLL(2)<br>
for (k = 0; k < 8; k += 4)<br>
{<br>
int32x4_t s[4];<br>
@@ -584,7 +592,7 @@ static void partialButterflyInverse16_neon(const int16_t *src, int16_t *orig_dst<br>
}<br>
<br>
<br>
-#pragma unroll(2)<br>
+X265_PRAGMA_UNROLL(2)<br>
for (k = 0; k < 8; k += 4)<br>
{<br>
int32x4_t t;<br>
@@ -657,10 +665,10 @@ static void partialButterflyInverse32_neon(const int16_t *src, int16_t *orig_dst<br>
int16x4_t dst[32];<br>
int add = 1 << (shift - 1);<br>
<br>
-#pragma unroll (8)<br>
+X265_PRAGMA_UNROLL(8)<br>
for (j = 0; j < line; j += 4)<br>
{<br>
-#pragma unroll (4)<br>
+X265_PRAGMA_UNROLL(4)<br>
for (k = 0; k < 16; k += 4)<br>
{<br>
int32x4_t s[4];<br>
@@ -681,7 +689,7 @@ static void partialButterflyInverse32_neon(const int16_t *src, int16_t *orig_dst<br>
}<br>
<br>
<br>
-#pragma unroll (2)<br>
+X265_PRAGMA_UNROLL(2)<br>
for (k = 0; k < 8; k += 4)<br>
{<br>
int32x4_t s[4];<br>
@@ -721,7 +729,7 @@ static void partialButterflyInverse32_neon(const int16_t *src, int16_t *orig_dst<br>
EEO[k + 3] = s[3];<br>
}<br>
<br>
-#pragma unroll (2)<br>
+X265_PRAGMA_UNROLL(2)<br>
for (k = 0; k < 2; k++)<br>
{<br>
int32x4_t s;<br>
@@ -736,14 +744,14 @@ static void partialButterflyInverse32_neon(const int16_t *src, int16_t *orig_dst<br>
EEE[1] = vaddq_s32(EEEE[1], EEEO[1]);<br>
EEE[2] = vsubq_s32(EEEE[1], EEEO[1]);<br>
<br>
-#pragma unroll (4)<br>
+X265_PRAGMA_UNROLL(4)<br>
for (k = 0; k < 4; k++)<br>
{<br>
EE[k] = vaddq_s32(EEE[k], EEO[k]);<br>
EE[k + 4] = vsubq_s32((EEE[3 - k]), (EEO[3 - k]));<br>
}<br>
<br>
-#pragma unroll (8)<br>
+X265_PRAGMA_UNROLL(8)<br>
for (k = 0; k < 8; k++)<br>
{<br>
E[k] = vaddq_s32(EE[k], EO[k]);<br>
@@ -755,7 +763,7 @@ static void partialButterflyInverse32_neon(const int16_t *src, int16_t *orig_dst<br>
<br>
<br>
<br>
-#pragma unroll (16)<br>
+X265_PRAGMA_UNROLL(16)<br>
for (k = 0; k < 16; k++)<br>
{<br>
int32x4_t adde = vaddq_s32(vdupq_n_s32(add), E[k]);<br>
@@ -777,7 +785,7 @@ static void partialButterflyInverse32_neon(const int16_t *src, int16_t *orig_dst<br>
}<br>
<br>
<br>
-#pragma unroll (8)<br>
+X265_PRAGMA_UNROLL(8)<br>
for (k = 0; k < 32; k += 4)<br>
{<br>
int16x4_t x0 = dst[k + 0];<br>
-- <br>
2.42.1<o:p></o:p></span></p>
</div>
</div>
</div>
</div>
IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose,
or store or copy the information in any medium. Thank you.
</body>
</html>