<div style="line-height:1.7;color:#000000;font-size:14px;font-family:Arial"><div style="margin: 0;">I have no idea to <span style="color: rgb(51, 51, 51); font-family: Arial, "PingFang SC", "Hiragino Sans GB", STHeiti, "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif; background-color: rgb(249, 249, 249);">significant improve performance, </span>the macro helpful code readable.</div><div style="margin: 0;">some little comment:</div><div style="margin: 0;">move SUB follow by LD1 will hidden memory operator latency, also mixed ST1 with next LD1, etc.</div><div style="margin: 0;">But in these case the code readable became bad, so I do not suggest these adjust.</div><div style="margin: 0;"><br></div><div style="margin: 0;">Regards,</div><div style="margin: 0;">Min Chen</div><p>At 2021-07-31 12:14:29, "Pop, Sebastian" <spop@amazon.com> wrote:</p><blockquote id="isReplyContent" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">
<style><!--
_font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
_font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
font-size:12.0pt;
font-family:"Calibri",sans-serif;}
span.EmailStyle21
{mso-style-type:personal-reply;
font-family:"Calibri",sans-serif;
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;}
_page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style>
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt">Hi,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">Please let me know if you have ideas on how to make this code faster.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">I tried to remove the stall by fetching more memory earlier, still no change in performance:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">// void scale2D_64to32(pixel* dst, const pixel* src, intptr_t stride)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">function x265_scale2D_64to32_neon<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> mov w12, #15<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> ld1 {v0.16b-v3.16b}, [x1], x2<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> ld1 {v4.16b-v7.16b}, [x1], x2<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">.loop_scale2D:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> sub w12, w12, #1<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> ld1 {v20.16b-v23.16b}, [x1], x2<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> ld1 {v24.16b-v27.16b}, [x1], x2<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> scale2D_1 v0, v1, v2, v3, v4, v5, v6, v7<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> ld1 {v0.16b-v3.16b}, [x1], x2<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> ld1 {v4.16b-v7.16b}, [x1], x2<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> scale2D_1 v20, v21, v22, v23, v24, v25, v26, v27<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> cbnz w12, .loop_scale2D<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> ld1 {v20.16b-v23.16b}, [x1], x2<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> ld1 {v24.16b-v27.16b}, [x1], x2<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> scale2D_1 v0, v1, v2, v3, v4, v5, v6, v7<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> scale2D_1 v20, v21, v22, v23, v24, v25, v26, v27<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> ret<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">endfunc<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">.macro scale2D_1 v0, v1, v2, v3, v4, v5, v6, v7<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> uaddlp \v0\().8h, \v0\().16b<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> uaddlp \v1\().8h, \v1\().16b<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> uaddlp \v2\().8h, \v2\().16b<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> uaddlp \v3\().8h, \v3\().16b<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> uaddlp \v4\().8h, \v4\().16b<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> uaddlp \v5\().8h, \v5\().16b<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> uaddlp \v6\().8h, \v6\().16b<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> uaddlp \v7\().8h, \v7\().16b<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> add \v0\().8h, \v0\().8h, \v4\().8h<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> add \v1\().8h, \v1\().8h, \v5\().8h<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> add \v2\().8h, \v2\().8h, \v6\().8h<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> add \v3\().8h, \v3\().8h, \v7\().8h<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> uqrshrn \v0\().8b, \v0\().8h, #2<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> uqrshrn2 \v0\().16b, \v1\().8h, #2<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> uqrshrn \v1\().8b, \v2\().8h, #2<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> uqrshrn2 \v1\().16b, \v3\().8h, #2<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> st1 {\v0\().16b-\v1\().16b}, [x0], #32<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">.endm<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">The only change that I did is to further optimize for code size by re-rolling the loop that was unrolled 2x.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">No change in performance, and 2x smaller code.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">Sebastian<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
</div>
</blockquote></div>